[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2d158fc5-a0b5-718d-d70a-3dfe9db22482@suse.com>
Date: Fri, 29 May 2020 08:09:38 -0700
From: Lee Duncan <lduncan@...e.com>
To: <wu000273@....edu>, <kjlu@....edu>
CC: Chris Leech <cleech@...hat.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
<open-iscsi@...glegroups.com>, <linux-scsi@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scsi: Fix reference count leak in iscsi_boot_create_kobj.
On 5/28/20 1:13 PM, wu000273@....edu wrote:
> From: Qiushi Wu <wu000273@....edu>
>
> kobject_init_and_add() should be handled when it return an error,
> because 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. Previous
> commit "b8eb718348b8" fixed a similar problem. Thus replace calling
> kfree() by calling kobject_put().
>
> Signed-off-by: Qiushi Wu <wu000273@....edu>
> ---
> drivers/scsi/iscsi_boot_sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/iscsi_boot_sysfs.c b/drivers/scsi/iscsi_boot_sysfs.c
> index e4857b728033..a64abe38db2d 100644
> --- a/drivers/scsi/iscsi_boot_sysfs.c
> +++ b/drivers/scsi/iscsi_boot_sysfs.c
> @@ -352,7 +352,7 @@ iscsi_boot_create_kobj(struct iscsi_boot_kset *boot_kset,
> boot_kobj->kobj.kset = boot_kset->kset;
> if (kobject_init_and_add(&boot_kobj->kobj, &iscsi_boot_ktype,
> NULL, name, index)) {
> - kfree(boot_kobj);
> + kobject_put(&boot_kobj->kobj);
> return NULL;
> }
> boot_kobj->data = data;
>
Reviewed-by: Lee Duncan <lduncan@...e.com>
Powered by blists - more mailing lists