Commit b3edd84c authored by Joe Hattori's avatar Joe Hattori Committed by Wen Zhiwei
Browse files

platform/x86: mlx-platform: call pci_dev_put() to balance the refcount

stable inclusion
from stable-v6.6.70
commit 23ea763880d6967615c23f690edd502ac794f38b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBOHV1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=23ea763880d6967615c23f690edd502ac794f38b



--------------------------------

[ Upstream commit 185e1b1d91e419445d3fd99c1c0376a970438acf ]

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: 02daa222 ("platform: mellanox: Add initial support for PCIe based programming logic device")
Signed-off-by: default avatarJoe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Reviewed-by: default avatarVadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20241216022538.381209-1-joe@pf.is.s.u-tokyo.ac.jp


Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent f45b59bd
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6237,6 +6237,7 @@ mlxplat_pci_fpga_device_init(unsigned int device, const char *res_name, struct p
fail_pci_request_regions:
	pci_disable_device(pci_dev);
fail_pci_enable_device:
	pci_dev_put(pci_dev);
	return err;
}

@@ -6247,6 +6248,7 @@ mlxplat_pci_fpga_device_exit(struct pci_dev *pci_bridge,
	iounmap(pci_bridge_addr);
	pci_release_regions(pci_bridge);
	pci_disable_device(pci_bridge);
	pci_dev_put(pci_bridge);
}

static int