Re: [PATCH] scsi: Fix reference count leak in iscsi_boot_create_kobj.

11 views
Skip to first unread message

Lee Duncan

unread,
May 29, 2020, 11:13:10 AM5/29/20
to wu00...@umn.edu, kj...@umn.edu, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, linux-...@vger.kernel.org
On 5/28/20 1:13 PM, wu00...@umn.edu wrote:
> From: Qiushi Wu <wu00...@umn.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 <wu00...@umn.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 <ldu...@suse.com>

wu00...@umn.edu

unread,
Jun 1, 2020, 9:54:48 AM6/1/20
to kj...@umn.edu, wu00...@umn.edu, Lee Duncan, Chris Leech, James E.J. Bottomley, Martin K. Petersen, open-...@googlegroups.com, linux...@vger.kernel.org, linux-...@vger.kernel.org
--
2.17.1

Martin K. Petersen

unread,
Jun 2, 2020, 10:32:00 PM6/2/20
to kj...@umn.edu, wu00...@umn.edu, Martin K . Petersen, Lee Duncan, open-...@googlegroups.com, James E.J. Bottomley, linux...@vger.kernel.org, Chris Leech, linux-...@vger.kernel.org
On Thu, 28 May 2020 15:13:53 -0500, wu00...@umn.edu wrote:

> 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().

Applied to 5.8/scsi-queue, thanks!

[1/1] scsi: iscsi: Fix reference count leak in iscsi_boot_create_kobj
https://git.kernel.org/mkp/scsi/c/0267ffce562c

--
Martin K. Petersen Oracle Linux Engineering

Qiushi Wu

unread,
Jun 5, 2020, 11:51:23 PM6/5/20
to Martin K. Petersen, Chris Leech, James E.J. Bottomley, Lee Duncan, kj...@umn.edu, linux-...@vger.kernel.org, linux...@vger.kernel.org, open-...@googlegroups.com
Thanks!
Reply all
Reply to author
Forward
0 new messages