All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] RDMA/usnic: drop redundant kobject_get() in usnic_ib_sysfs_register_usdev()
@ 2026-12-02 11:03 Ziheng Wei
  2026-12-02 11:07 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ziheng Wei @ 2026-12-02 11:03 UTC (permalink / raw)
  To: Nelson Escobar, Satish Kharat, Jason Gunthorpe, Leon Romanovsky
  Cc: linux-rdma, linux-kernel, stable

usnic_ib_sysfs_register_usdev() takes an explicit reference on
&us_ibdev->ib_dev.dev.kobj before calling kobject_create_and_add("qpn",
&us_ibdev->ib_dev.dev.kobj). However, kobject_create_and_add() already
takes a reference on the parent kobject (and releases it when qpn_kobj is
cleaned up), while usnic_ib_sysfs_unregister_usdev() only calls
kobject_put(us_ibdev->qpn_kobj). The extra reference on
&us_ibdev->ib_dev.dev.kobj is therefore leaked on every successful
registration, preventing ib_dev release on unregister.

Remove the redundant kobject_get() and its error-path kobject_put().

Found by LLM-assisted static analysis. Compile-tested on x86_64.

Fixes: e3cf00d0a87f ("IB/usnic: Add Cisco VIC low-level hardware driver")
Cc: stable@vger.kernel.org
Signed-off-by: Ziheng Wei <zihengw03@163.com>
---
 drivers/infiniband/hw/usnic/usnic_ib_sysfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
index fdb63a8fb..3f3326444 100644
--- a/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
+++ b/drivers/infiniband/hw/usnic/usnic_ib_sysfs.c
@@ -252,13 +252,10 @@ static struct kobj_type usnic_ib_qpn_type = {
 int usnic_ib_sysfs_register_usdev(struct usnic_ib_dev *us_ibdev)
 {
 	/* create kernel object for looking at individual QPs */
-	kobject_get(&us_ibdev->ib_dev.dev.kobj);
 	us_ibdev->qpn_kobj = kobject_create_and_add("qpn",
 			&us_ibdev->ib_dev.dev.kobj);
-	if (us_ibdev->qpn_kobj == NULL) {
-		kobject_put(&us_ibdev->ib_dev.dev.kobj);
+	if (!us_ibdev->qpn_kobj)
 		return -ENOMEM;
-	}
 
 	return 0;
 }

base-commit: 97d73c8251226cf27cc6656b4c542869bb8c69fa
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 11:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 11:03 [PATCH] RDMA/usnic: drop redundant kobject_get() in usnic_ib_sysfs_register_usdev() Ziheng Wei
2026-12-02 11:07 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.