[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <MW3PR11MB4665C9149B684B4B9F00AFF5F48E0@MW3PR11MB4665.namprd11.prod.outlook.com>
Date: Thu, 28 May 2020 12:05:57 +0000
From: "Wan, Kaike" <kaike.wan@...el.com>
To: "wu000273@....edu" <wu000273@....edu>,
"kjlu@....edu" <kjlu@....edu>
CC: "Dalessandro, Dennis" <dennis.dalessandro@...el.com>,
"Marciniszyn, Mike" <mike.marciniszyn@...el.com>,
Doug Ledford <dledford@...hat.com>,
"Jason Gunthorpe" <jgg@...pe.ca>,
"linux-rdma@...r.kernel.org" <linux-rdma@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] RDMA/qib: Fix several reference count leak
qib_create_port_files
> -----Original Message-----
> From: linux-rdma-owner@...r.kernel.org <linux-rdma-
> owner@...r.kernel.org> On Behalf Of wu000273@....edu
> Sent: Wednesday, May 27, 2020 10:41 PM
> To: kjlu@....edu
> Cc: wu000273@....edu; Dalessandro, Dennis
> <dennis.dalessandro@...el.com>; Marciniszyn, Mike
> <mike.marciniszyn@...el.com>; Doug Ledford <dledford@...hat.com>;
> Jason Gunthorpe <jgg@...pe.ca>; linux-rdma@...r.kernel.org; linux-
> kernel@...r.kernel.org
> Subject: [PATCH] RDMA/qib: Fix several reference count leak
> qib_create_port_files
>
> From: Qiushi Wu <wu000273@....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@....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
Powered by blists - more mailing lists