lkml.org 
[lkml]   [2020]   [May]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH] RDMA/qib: Fix several reference count leak qib_create_port_files
Date
> -----Original Message-----
> From: linux-rdma-owner@vger.kernel.org <linux-rdma-
> owner@vger.kernel.org> On Behalf Of wu000273@umn.edu
> Sent: Wednesday, May 27, 2020 10:41 PM
> To: kjlu@umn.edu
> Cc: wu000273@umn.edu; Dalessandro, Dennis
> <dennis.dalessandro@intel.com>; Marciniszyn, Mike
> <mike.marciniszyn@intel.com>; Doug Ledford <dledford@redhat.com>;
> Jason Gunthorpe <jgg@ziepe.ca>; linux-rdma@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: [PATCH] RDMA/qib: Fix several reference count leak
> qib_create_port_files
>
> From: Qiushi Wu <wu000273@umn.edu>
>
> kobject_init_and_add() takes reference even when it fails.
> If this function returns an error, kobject_put() must be called to properly
> clean up the memory associated with the object. To fix these issues, we
> correct the jump targets when the calls of
> kobject_init_and_add() fail, to make sure they can be handled by
> kobject_put(). Previous commit "b8eb718348b8" fixed a similar problem.
>
> Signed-off-by: Qiushi Wu <wu000273@umn.edu>
> ---
> drivers/infiniband/hw/qib/qib_sysfs.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c
> b/drivers/infiniband/hw/qib/qib_sysfs.c
> index 568b21eb6ea1..017ed82070f9 100644
> --- a/drivers/infiniband/hw/qib/qib_sysfs.c
> +++ b/drivers/infiniband/hw/qib/qib_sysfs.c
> @@ -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);
> --
> 2.17.1
Already fixed:

https://marc.info/?l=linux-rdma&m=158925321102485&w=2

Kaike

\
 
 \ /
  Last update: 2020-05-28 14:07    [W:0.051 / U:0.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site