linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rakesh Pandit <rakesh@tuxera.com>
To: "Javier González" <jg@lightnvm.io>
Cc: "Matias Bjørling" <mb@lightnvm.io>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lightnvm: pblk: fix error path in pblk_lines_alloc_metadata
Date: Thu, 21 Sep 2017 13:15:04 +0300	[thread overview]
Message-ID: <20170921101504.GA27665@dhcp-216.srv.tuxera.com> (raw)
In-Reply-To: <032D1EF1-4F4A-45E1-BE6C-B8C9C9E0F6F7@lightnvm.io>

On Thu, Sep 21, 2017 at 11:56:46AM +0200, Javier Gonz�lez wrote:
> > On 20 Sep 2017, at 21.50, Rakesh Pandit <rakesh@tuxera.com> wrote:
> > 
> > Use appropriate memory free calls based on allocation type used and
> > also fix number of times free is called if kmalloc fails.
> > 
> > Signed-off-by: Rakesh Pandit <rakesh@tuxera.com>
> > ---
> > drivers/lightnvm/pblk-init.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
> > index 7cf4b53..470ef04 100644
> > --- a/drivers/lightnvm/pblk-init.c
> > +++ b/drivers/lightnvm/pblk-init.c
> > @@ -624,12 +624,16 @@ static int pblk_lines_alloc_metadata(struct pblk *pblk)
> > 
> > fail_free_emeta:
> > 	while (--i >= 0) {
> > -		vfree(l_mg->eline_meta[i]->buf);
> > +		if (l_mg->emeta_alloc_type == PBLK_VMALLOC_META)
> > +			vfree(l_mg->eline_meta[i]->buf);
> > +		else
> > +			kfree(l_mg->eline_meta[i]->buf);
> > 		kfree(l_mg->eline_meta[i]);
> > 	}
> > 
> > +	i = PBLK_DATA_LINES;
> > fail_free_smeta:
> > -	for (i = 0; i < PBLK_DATA_LINES; i++)
> > +	while (--i >= 0)
> > 		kfree(l_mg->sline_meta[i]);
> 
> It is safe to use kfree on NULL pointers. No need to do this. You can
> either send a new patch, or we can change it when picking it up.

Yes, that would be great if this is adjusted while picking up.

> 
> > 
> > 	return -ENOMEM;
> > --
> > 2.5.0
> 
> Rest looks good.
> 
> 
> Reviewed-by: Javier Gonz�lez <javier@cnexlabs.com>
> 

Thanks,

  reply	other threads:[~2017-09-21 10:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20 19:50 [PATCH] lightnvm: pblk: fix error path in pblk_lines_alloc_metadata Rakesh Pandit
2017-09-21  9:56 ` Javier González
2017-09-21 10:15   ` Rakesh Pandit [this message]
2017-09-21 11:14     ` Matias Bjørling

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=20170921101504.GA27665@dhcp-216.srv.tuxera.com \
    --to=rakesh@tuxera.com \
    --cc=jg@lightnvm.io \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mb@lightnvm.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).