Skip to content

Commit 185e1b1

Browse files
joehattoriij-intel
authored andcommitted
platform/x86: mlx-platform: call pci_dev_put() to balance the refcount
mlxplat_pci_fpga_device_init() calls pci_get_device() but does not release the refcount on error path. Call pci_dev_put() on the error path and in mlxplat_pci_fpga_device_exit() to fix this. This bug was found by an experimental static analysis tool that I am developing. Fixes: 02daa22 ("platform: mellanox: Add initial support for PCIe based programming logic device") Signed-off-by: Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp> Reviewed-by: Vadim Pasternak <vadimp@nvidia.com> Link: https://lore.kernel.org/r/20241216022538.381209-1-joe@pf.is.s.u-tokyo.ac.jp Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
1 parent 83848e3 commit 185e1b1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/platform/x86/mlx-platform.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6237,6 +6237,7 @@ mlxplat_pci_fpga_device_init(unsigned int device, const char *res_name, struct p
62376237
fail_pci_request_regions:
62386238
pci_disable_device(pci_dev);
62396239
fail_pci_enable_device:
6240+
pci_dev_put(pci_dev);
62406241
return err;
62416242
}
62426243

@@ -6247,6 +6248,7 @@ mlxplat_pci_fpga_device_exit(struct pci_dev *pci_bridge,
62476248
iounmap(pci_bridge_addr);
62486249
pci_release_regions(pci_bridge);
62496250
pci_disable_device(pci_bridge);
6251+
pci_dev_put(pci_bridge);
62506252
}
62516253

62526254
static int

0 commit comments

Comments
 (0)