]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
IB/qib: Call kobject_put() when kobject_init_and_add() fails
authorKaike Wan <kaike.wan@intel.com>
Tue, 12 May 2020 03:13:28 +0000 (23:13 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Tue, 19 May 2020 23:58:03 +0000 (20:58 -0300)
commita35cd6447effd5c239b564c80fa109d05ff3d114
tree9caacdf383d6ced0c078dc02a20a385c340873d6
parentb9bbe6ed63b2b9f2c9ee5cbd0f2c946a2723f4ce
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: f931551bafe1 ("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>
drivers/infiniband/hw/qib/qib_sysfs.c