Message ID | 20221117123301.42916-1-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net] bnx2x: fix pci device refcount leak in bnx2x_vf_is_pcie_pending() | expand |
On Thu, 17 Nov 2022 20:33:01 +0800 Yang Yingliang wrote: > diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c > index 11d15cd03600..cd5108b38542 100644 > --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c > +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c > @@ -802,8 +802,11 @@ static u8 bnx2x_vf_is_pcie_pending(struct bnx2x *bp, u8 abs_vfid) > return false; > > dev = pci_get_domain_bus_and_slot(vf->domain, vf->bus, vf->devfn); > - if (dev) > - return bnx2x_is_pcie_pending(dev); > + if (dev) { > + bool pending = bnx2x_is_pcie_pending(dev); > + pci_dev_put(dev); > + return pending; > + } > return false; Success path should be unindented: dev = pci_get.. if (!dev) return false; pending = bnxt2x_is_... pci_dev_put(dev); return pending; Please use get_maintainers on the formatted patch file to find all the people to CC.
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index 11d15cd03600..cd5108b38542 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c @@ -802,8 +802,11 @@ static u8 bnx2x_vf_is_pcie_pending(struct bnx2x *bp, u8 abs_vfid) return false; dev = pci_get_domain_bus_and_slot(vf->domain, vf->bus, vf->devfn); - if (dev) - return bnx2x_is_pcie_pending(dev); + if (dev) { + bool pending = bnx2x_is_pcie_pending(dev); + pci_dev_put(dev); + return pending; + } return false; }
As comment of pci_get_domain_bus_and_slot() says, it returns a pci device with refcount increment, when finish using it, the caller must decrement the reference count by calling pci_dev_put(). Call pci_dev_put() before returning from bnx2x_vf_is_pcie_pending() to avoid refcount leak. Fixes: b56e9670ffa4 ("bnx2x: Prepare device and initialize VF database") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)