mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 09:36:22 +02:00
net: liquidio: fix BAR resource leak on PF number failure
If cn23xx_get_pf_num() fails, the function returns without
unmapping either BAR. Unmap both BARs before returning from
the error path.
Found by manual code review.
Fixes: 0c45d7fe12 ("liquidio: fix use of pf in pass-through mode in a virtual machine")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com>
Link: https://patch.msgid.link/20260624064013.2809570-1-haoxiang_li2024@163.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
96ca1e658a
commit
c63ee62a3c
|
|
@ -1163,18 +1163,14 @@ int setup_cn23xx_octeon_pf_device(struct octeon_device *oct)
|
|||
if (octeon_map_pci_barx(oct, 1, MAX_BAR1_IOREMAP_SIZE)) {
|
||||
dev_err(&oct->pci_dev->dev, "%s CN23XX BAR1 map failed\n",
|
||||
__func__);
|
||||
octeon_unmap_pci_barx(oct, 0);
|
||||
return 1;
|
||||
goto err_unmap_bar0;
|
||||
}
|
||||
|
||||
if (cn23xx_get_pf_num(oct) != 0)
|
||||
return 1;
|
||||
goto err_unmap_bar1;
|
||||
|
||||
if (cn23xx_sriov_config(oct)) {
|
||||
octeon_unmap_pci_barx(oct, 0);
|
||||
octeon_unmap_pci_barx(oct, 1);
|
||||
return 1;
|
||||
}
|
||||
if (cn23xx_sriov_config(oct))
|
||||
goto err_unmap_bar1;
|
||||
|
||||
octeon_write_csr64(oct, CN23XX_SLI_MAC_CREDIT_CNT, 0x3F802080802080ULL);
|
||||
|
||||
|
|
@ -1205,6 +1201,12 @@ int setup_cn23xx_octeon_pf_device(struct octeon_device *oct)
|
|||
oct->coproc_clock_rate = 1000000ULL * cn23xx_coprocessor_clock(oct);
|
||||
|
||||
return 0;
|
||||
|
||||
err_unmap_bar1:
|
||||
octeon_unmap_pci_barx(oct, 1);
|
||||
err_unmap_bar0:
|
||||
octeon_unmap_pci_barx(oct, 0);
|
||||
return 1;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(setup_cn23xx_octeon_pf_device);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user