IB/hfi1: Call kobject_put() when kobject_init_and_add() fails
authorKaike Wan <kaike.wan@intel.com>
Thu, 26 Mar 2020 16:38:14 +0000 (12:38 -0400)
committerJason Gunthorpe <jgg@mellanox.com>
Fri, 27 Mar 2020 16:13:36 +0000 (13:13 -0300)
commitdfb5394f804ed4fcea1fc925be275a38d66712ab
tree65d182d7cfb6539406444c0aedd725321ca6c5f1
parent5c15abc4328ad696fa61e2f3604918ed0c207755
IB/hfi1: Call kobject_put() when kobject_init_and_add() fails

When kobject_init_and_add() returns an error in the function
hfi1_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.

Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20200326163813.21129.44280.stgit@awfm-01.aw.intel.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>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
drivers/infiniband/hw/hfi1/sysfs.c