From: Mike Snitzer <snitzer@redhat.com>
To: Colin King <colin.king@canonical.com>
Cc: Alasdair Kergon <agk@redhat.com>,
dm-devel@redhat.com, Damien Le Moal <damien.lemoal@wdc.com>,
Hannes Reinecke <hare@suse.de>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] dm zoned: fix memory leak of newly allocated zone on xa_insert failure
Date: Wed, 3 Jun 2020 14:18:45 -0400 [thread overview]
Message-ID: <20200603181845.GA20491@redhat.com> (raw)
In-Reply-To: <20200603160254.142222-1-colin.king@canonical.com>
On Wed, Jun 03 2020 at 12:02pm -0400,
Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.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@canonical.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.
WARNING: multiple messages have this Message-ID (diff)
From: Mike Snitzer <snitzer@redhat.com>
To: Colin King <colin.king@canonical.com>
Cc: Alasdair Kergon <agk@redhat.com>,
dm-devel@redhat.com, Damien Le Moal <damien.lemoal@wdc.com>,
Hannes Reinecke <hare@suse.de>,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] dm zoned: fix memory leak of newly allocated zone on xa_insert failure
Date: Wed, 03 Jun 2020 18:18:45 +0000 [thread overview]
Message-ID: <20200603181845.GA20491@redhat.com> (raw)
In-Reply-To: <20200603160254.142222-1-colin.king@canonical.com>
On Wed, Jun 03 2020 at 12:02pm -0400,
Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.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@canonical.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.
next prev parent reply other threads:[~2020-06-03 18:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 16:02 [PATCH][next] dm zoned: fix memory leak of newly allocated zone on xa_insert failure Colin King
2020-06-03 16:02 ` Colin King
2020-06-03 18:18 ` Mike Snitzer [this message]
2020-06-03 18:18 ` Mike Snitzer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200603181845.GA20491@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=colin.king@canonical.com \
--cc=damien.lemoal@wdc.com \
--cc=dm-devel@redhat.com \
--cc=hare@suse.de \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.