From: Artem Bityutskiy <dedekind1@gmail.com>
To: Scott Wood <scottwood@freescale.com>
Cc: linuxppc-dev@ozlabs.org, b35362@freescale.com,
dwmw2@infradead.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH 1/2] mtd/nand : don't free the global data fsl_lbc_ctrl_dev->nand in fsl_elbc_chip_remove()
Date: Thu, 30 Jun 2011 14:53:13 +0300 [thread overview]
Message-ID: <1309434797.23597.178.camel@sauron> (raw)
In-Reply-To: <20110629114558.13975519@schlenkerla.am.freescale.net>
On Wed, 2011-06-29 at 11:45 -0500, Scott Wood wrote:
> On Wed, 29 Jun 2011 09:20:25 +0300
> Artem Bityutskiy <dedekind1@gmail.com> wrote:
>
> > On Tue, 2011-06-28 at 09:50 +0800, b35362@freescale.com wrote:
> > > From: Liu Shuo <b35362@freescale.com>
> > >
> > > The global data fsl_lbc_ctrl_dev->nand don't have to be freed in
> > > fsl_elbc_chip_remove(). The right place to do that is in fsl_elbc_nand_remove()
> > > if elbc_fcm_ctrl->counter is zero.
> > >
> > > Signed-off-by: Liu Shuo <b35362@freescale.com>
> > > ---
> > > drivers/mtd/nand/fsl_elbc_nand.c | 1 -
> > > 1 files changed, 0 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
> > > index 0bb254c..a212116 100644
> > > --- a/drivers/mtd/nand/fsl_elbc_nand.c
> > > +++ b/drivers/mtd/nand/fsl_elbc_nand.c
> > > @@ -829,7 +829,6 @@ static int fsl_elbc_chip_remove(struct fsl_elbc_mtd *priv)
> > >
> > > elbc_fcm_ctrl->chips[priv->bank] = NULL;
> > > kfree(priv);
> > > - kfree(elbc_fcm_ctrl);
> > > return 0;
> > > }
> >
> > Do we have to assign fsl_lbc_ctrl_dev->nand to NULL in
> > fsl_elbc_nand_remove() then? I think that assignment can be killed then.
> >
> > if (!elbc_fcm_ctrl->counter) {
> > fsl_lbc_ctrl_dev->nand = NULL;
> > kfree(elbc_fcm_ctrl);
> > }
> >
>
> If we're freeing fsl_lbc_ctrl, we'd better get rid of references to it...
Yes, on the one hand this is a good defensive programming practice, on
the other hand it hides double-free bugs. Like this patch fixes a
double-free bug, and why it was noticed before? I thought may be because
of this NULL assignment?
I do not insist though, that was just a suggestion/question.
--
Best Regards,
Artem Bityutskiy
next prev parent reply other threads:[~2011-06-30 11:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-28 1:50 [PATCH 1/2] mtd/nand : don't free the global data fsl_lbc_ctrl_dev->nand in fsl_elbc_chip_remove() b35362
2011-06-28 1:50 ` [PATCH 2/2] mtd/nand : workaround for Freescale FCM to support large-page Nand chip b35362
2011-06-28 15:35 ` [PATCH 2/2] mtd/nand : workaround for Freescale FCM to supportlarge-page " Mike Hench
2011-06-28 16:30 ` Scott Wood
2011-06-29 6:22 ` [PATCH 2/2] mtd/nand : workaround for Freescale FCM to support large-page " Artem Bityutskiy
2011-06-29 16:43 ` Scott Wood
2011-06-30 11:51 ` Artem Bityutskiy
2011-06-29 6:20 ` [PATCH 1/2] mtd/nand : don't free the global data fsl_lbc_ctrl_dev->nand in fsl_elbc_chip_remove() Artem Bityutskiy
2011-06-29 16:45 ` Scott Wood
2011-06-30 11:53 ` Artem Bityutskiy [this message]
2011-06-30 16:26 ` Scott Wood
2011-07-01 5:40 ` Artem Bityutskiy
2011-07-01 16:14 ` Scott Wood
2011-07-06 6:46 ` Artem Bityutskiy
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=1309434797.23597.178.camel@sauron \
--to=dedekind1@gmail.com \
--cc=b35362@freescale.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=scottwood@freescale.com \
/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).