lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 21 Jan 2022 18:57:59 +0900
From:   Damien Le Moal <damien.lemoal@...nsource.wdc.com>
To:     Miaoqian Lin <linmq006@...il.com>, Jens Axboe <axboe@...nel.dk>,
        Hannes Reinecke <hare@...e.de>,
        Keith Busch <kbusch@...nel.org>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Damien Le Moal <damien.lemoal@....com>,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] block: fix memory leak in
 disk_register_independent_access_ranges

On 1/20/22 19:10, Miaoqian Lin wrote:
> kobject_init_and_add() takes reference even when it fails.
> According to the doc of kobject_init_and_add()
> 
>    If this function returns an error, kobject_put() must be called to
>    properly clean up the memory associated with the object.
> 
> Fix this issue by adding kobject_put().
> Callback function blk_ia_ranges_sysfs_release() in kobject_put()
> can handle the pointer "iars" properly.
> 
> Fixes: a2247f19ee1c ("block: Add independent access ranges support")
> Signed-off-by: Miaoqian Lin <linmq006@...il.com>
> ---
>  block/blk-ia-ranges.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/blk-ia-ranges.c b/block/blk-ia-ranges.c
> index b925f3db3ab7..18c68d8b9138 100644
> --- a/block/blk-ia-ranges.c
> +++ b/block/blk-ia-ranges.c
> @@ -144,7 +144,7 @@ int disk_register_independent_access_ranges(struct gendisk *disk,
>  				   &q->kobj, "%s", "independent_access_ranges");
>  	if (ret) {
>  		q->ia_ranges = NULL;
> -		kfree(iars);
> +		kobject_put(&iars->kobj);
>  		return ret;
>  	}
>  

Looks good.

Reviewed-by: Damien Le Moal <damien.lemoal@...nsource.wdc.com>

-- 
Damien Le Moal
Western Digital Research

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ