mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
IB/qib: Call kobject_put() when kobject_init_and_add() fails
When kobject_init_and_add() returns an error in the function
qib_create_port_files(), the function kobject_put() is not called for the
corresponding kobject, which potentially leads to memory leak.
This patch fixes the issue by calling kobject_put() even if
kobject_init_and_add() fails. In addition, the ppd->diagc_kobj is released
along with other kobjects when the sysfs is unregistered.
Fixes: f931551baf
("IB/qib: Add new qib driver for QLogic PCIe InfiniBand adapters")
Link: https://lore.kernel.org/r/20200512031328.189865.48627.stgit@awfm-01.aw.intel.com
Cc: <stable@vger.kernel.org>
Suggested-by: Lin Yi <teroincn@gmail.com>
Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Kaike Wan <kaike.wan@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
parent
b9bbe6ed63
commit
a35cd6447e
1 changed files with 5 additions and 4 deletions
|
@ -760,7 +760,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,
|
|||
qib_dev_err(dd,
|
||||
"Skipping linkcontrol sysfs info, (err %d) port %u\n",
|
||||
ret, port_num);
|
||||
goto bail;
|
||||
goto bail_link;
|
||||
}
|
||||
kobject_uevent(&ppd->pport_kobj, KOBJ_ADD);
|
||||
|
||||
|
@ -770,7 +770,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,
|
|||
qib_dev_err(dd,
|
||||
"Skipping sl2vl sysfs info, (err %d) port %u\n",
|
||||
ret, port_num);
|
||||
goto bail_link;
|
||||
goto bail_sl;
|
||||
}
|
||||
kobject_uevent(&ppd->sl2vl_kobj, KOBJ_ADD);
|
||||
|
||||
|
@ -780,7 +780,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,
|
|||
qib_dev_err(dd,
|
||||
"Skipping diag_counters sysfs info, (err %d) port %u\n",
|
||||
ret, port_num);
|
||||
goto bail_sl;
|
||||
goto bail_diagc;
|
||||
}
|
||||
kobject_uevent(&ppd->diagc_kobj, KOBJ_ADD);
|
||||
|
||||
|
@ -793,7 +793,7 @@ int qib_create_port_files(struct ib_device *ibdev, u8 port_num,
|
|||
qib_dev_err(dd,
|
||||
"Skipping Congestion Control sysfs info, (err %d) port %u\n",
|
||||
ret, port_num);
|
||||
goto bail_diagc;
|
||||
goto bail_cc;
|
||||
}
|
||||
|
||||
kobject_uevent(&ppd->pport_cc_kobj, KOBJ_ADD);
|
||||
|
@ -854,6 +854,7 @@ void qib_verbs_unregister_sysfs(struct qib_devdata *dd)
|
|||
&cc_table_bin_attr);
|
||||
kobject_put(&ppd->pport_cc_kobj);
|
||||
}
|
||||
kobject_put(&ppd->diagc_kobj);
|
||||
kobject_put(&ppd->sl2vl_kobj);
|
||||
kobject_put(&ppd->pport_kobj);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue