linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	Akinobu Mita <mita@fixstars.com>,
	Vinayak Holikatti <vinholikatti@gmail.com>,
	Dolev Raviv <draviv@codeaurora.org>,
	Subhash Jadavani <subhashj@codeaurora.org>,
	Yaniv Gardi <ygardi@codeaurora.org>,
	Sujit Reddy Thumma <sthumma@codeaurora.org>,
	Maya Erez <merez@codeaurora.org>,
	Sahitya Tummala <stummala@codeaurora.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH -next] scsi: ufs: don't kfree() devm_kzalloc()'ed memory
Date: Wed, 26 Nov 2014 08:14:48 -0800	[thread overview]
Message-ID: <1417018488.2202.6.camel@HansenPartnership.com> (raw)
In-Reply-To: <CAC5umyhb=dpQVP3UhdKNXFUfQtoiH3E_4qNe76aeM0+wO-LOUg@mail.gmail.com>

On Thu, 2014-11-27 at 01:11 +0900, Akinobu Mita wrote:
> 2014-11-27 0:51 GMT+09:00 James Bottomley
> <James.Bottomley@hansenpartnership.com>:
> > On Thu, 2014-11-27 at 00:37 +0900, Akinobu Mita wrote:
> >> In ufshcd_parse_clock_info(), temporary memory allocated by
> >> devm_kzalloc() is released by kfree().  The devres mechanism cannot
> >> track the release and it causes trouble when removing the driver.
> >>
> >> Fix it by allocating it with plain kcalloc() instead of devm_kzalloc()
> >> as the temporary memory is always freed in that function.
> >>
> >> Signed-off-by: Akinobu Mita <mita@fixstars.com>
> >> Cc: Vinayak Holikatti <vinholikatti@gmail.com>
> >> Cc: Dolev Raviv <draviv@codeaurora.org>
> >> Cc: Subhash Jadavani <subhashj@codeaurora.org>
> >> Cc: Yaniv Gardi <ygardi@codeaurora.org>
> >> Cc: Sujit Reddy Thumma <sthumma@codeaurora.org>
> >> Cc: Maya Erez <merez@codeaurora.org>
> >> Cc: Sahitya Tummala <stummala@codeaurora.org>
> >> Cc: Christoph Hellwig <hch@lst.de>
> >> Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
> >> Cc: linux-scsi@vger.kernel.org
> >> ---
> >>  drivers/scsi/ufs/ufshcd-pltfrm.c | 3 +--
> >>  1 file changed, 1 insertion(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
> >> index 0c030ad..67b1f6c 100644
> >> --- a/drivers/scsi/ufs/ufshcd-pltfrm.c
> >> +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
> >> @@ -99,8 +99,7 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
> >>               goto out;
> >>       }
> >>
> >> -     clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq),
> >> -                     GFP_KERNEL);
> >> +     clkfreq = kcalloc(sz, sizeof(*clkfreq), GFP_KERNEL);
> >
> > I agree this doesn't need to be devm memory since it's copied into clki,
> > but where is it freed?  I think you need a kfree(clkfreq) at the bottom
> > of the routine.
> 
> Oops.  I was working on the older code, and blindly applied the -next just
> before sending this patch.  The problem I said in this commit log has been
> fixed by the commit e8cb64db81e8c88c5c824ca74c2e57b4c6919ca6 ("scsi: ufs:
> fix static checker warning in ufshcd_parse_clock_info").
> 
> So I withdraw this patch for now.  I will try with another title next time.

I don't necessarily disagree with the patch if you correct it.  In the
current state, clkfreq is only used as a temporary in the routine as you
say, but it persists the entire lifetime of the driver ... it's a tiny
amount of memory and the devm_ allocation ensures it eventually gets
cleaned up, so it's probably not that important in the grand scheme of
things.

James



      reply	other threads:[~2014-11-26 16:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-26 15:37 [PATCH -next] scsi: ufs: don't kfree() devm_kzalloc()'ed memory Akinobu Mita
2014-11-26 15:51 ` James Bottomley
2014-11-26 16:11   ` Akinobu Mita
2014-11-26 16:14     ` James Bottomley [this message]

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=1417018488.2202.6.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=akinobu.mita@gmail.com \
    --cc=draviv@codeaurora.org \
    --cc=hch@lst.de \
    --cc=linux-scsi@vger.kernel.org \
    --cc=merez@codeaurora.org \
    --cc=mita@fixstars.com \
    --cc=sthumma@codeaurora.org \
    --cc=stummala@codeaurora.org \
    --cc=subhashj@codeaurora.org \
    --cc=vinholikatti@gmail.com \
    --cc=ygardi@codeaurora.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 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).