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] [day] [month] [year] [list]
Message-ID: <20200603181845.GA20491@redhat.com>
Date:   Wed, 3 Jun 2020 14:18:45 -0400
From:   Mike Snitzer <snitzer@...hat.com>
To:     Colin King <colin.king@...onical.com>
Cc:     Alasdair Kergon <agk@...hat.com>, dm-devel@...hat.com,
        Damien Le Moal <damien.lemoal@....com>,
        Hannes Reinecke <hare@...e.de>,
        kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] dm zoned: fix memory leak of newly allocated zone
 on xa_insert failure

On Wed, Jun 03 2020 at 12:02pm -0400,
Colin King <colin.king@...onical.com> wrote:

> From: Colin Ian King <colin.king@...onical.com>
> 
> Currently if an xa_insert fails then there is a memory lead of the
> recently allocated zone object. Fix this by kfree'ing zone before
> returning on the error return path.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: 1a311efa3916 ("dm zoned: convert to xarray")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
> ---
>  drivers/md/dm-zoned-metadata.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
> index b23ff090c056..130b5a6d9f12 100644
> --- a/drivers/md/dm-zoned-metadata.c
> +++ b/drivers/md/dm-zoned-metadata.c
> @@ -313,8 +313,10 @@ static struct dm_zone *dmz_insert(struct dmz_metadata *zmd,
>  	if (!zone)
>  		return ERR_PTR(-ENOMEM);
>  
> -	if (xa_insert(&zmd->zones, zone_id, zone, GFP_KERNEL))
> +	if (xa_insert(&zmd->zones, zone_id, zone, GFP_KERNEL)) {
> +		kfree(zone);
>  		return ERR_PTR(-EBUSY);
> +	}
>  
>  	INIT_LIST_HEAD(&zone->link);
>  	atomic_set(&zone->refcount, 0);
> -- 
> 2.25.1
> 

Thanks, I folded this in.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ