diff mbox series

RDMA/hfi: Decrease PCI device reference count in error path

Message ID 20221117131546.113280-1-wangxiongfeng2@huawei.com (mailing list archive)
State Accepted
Headers show
Series RDMA/hfi: Decrease PCI device reference count in error path | expand

Commit Message

Xiongfeng Wang Nov. 17, 2022, 1:15 p.m. UTC
pci_get_device() will increase the reference count for the returned
pci_dev, and also decrease the reference count for the input parameter
*from* if it is not NULL.

If we break out the loop in node_affinity_init() with 'dev' not NULL, we
need to call pci_dev_put() to decrease the reference count. Add missing
pci_dev_put() in error path.

Fixes: c513de490f80 ("IB/hfi1: Invalid NUMA node information can cause a divide by zero")
Signed-off-by: Xiongfeng Wang <wangxiongfeng2@huawei.com>
---
 drivers/infiniband/hw/hfi1/affinity.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Leon Romanovsky Nov. 22, 2022, 9:50 a.m. UTC | #1
On Thu, 17 Nov 2022 21:15:46 +0800, Xiongfeng Wang wrote:
> pci_get_device() will increase the reference count for the returned
> pci_dev, and also decrease the reference count for the input parameter
> *from* if it is not NULL.
> 
> If we break out the loop in node_affinity_init() with 'dev' not NULL, we
> need to call pci_dev_put() to decrease the reference count. Add missing
> pci_dev_put() in error path.
> 
> [...]

Applied, thanks!

[1/1] RDMA/hfi: Decrease PCI device reference count in error path
      https://git.kernel.org/rdma/rdma/c/9b51d072da1d27

Best regards,
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c
index 877f8e84a672..77ee77d4000f 100644
--- a/drivers/infiniband/hw/hfi1/affinity.c
+++ b/drivers/infiniband/hw/hfi1/affinity.c
@@ -177,6 +177,8 @@  int node_affinity_init(void)
 	for (node = 0; node < node_affinity.num_possible_nodes; node++)
 		hfi1_per_node_cntr[node] = 1;
 
+	pci_dev_put(dev);
+
 	return 0;
 }