public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "devendra.aaru" <devendra.aaru@gmail.com>
Cc: Evgeniy Polyakov <zbr@ioremap.net>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/w1: free the w1_master at w1_free_dev and return a correct return value
Date: Thu, 21 Jun 2012 07:39:50 -0700	[thread overview]
Message-ID: <20120621143950.GA1818@kroah.com> (raw)
In-Reply-To: <CAHdPZaMfVz82_Rk1ywtX+Y95a3JsvjHGxUA1YJovQmmAQxn-OA@mail.gmail.com>

On Thu, Jun 21, 2012 at 10:14:53AM +0530, devendra.aaru wrote:
> Hi Greg,
> 
> On Thu, Jun 21, 2012 at 5:25 AM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> > On Sun, Jun 17, 2012 at 09:47:59PM +0530, Devendra Naga wrote:
> >> the w1_master pointer is allced at the w1_alloc_master and is not freed when called with
> >> w1_remove_master.
> >>
> >> when w1_alloc_dev fails the return should be -ENODEV as it does
> >> device_register, and that is the last case where that function
> >> will fail.
> >>
> >> Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
> >> Acked-by: Evgeniy Polyakov <zbr@ioremap.net>
> >> ---
> >>  drivers/w1/w1_int.c |    3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
> >> index 6828835..a3cf27d 100644
> >> --- a/drivers/w1/w1_int.c
> >> +++ b/drivers/w1/w1_int.c
> >> @@ -100,6 +100,7 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl,
> >>  static void w1_free_dev(struct w1_master *dev)
> >>  {
> >>       device_unregister(&dev->dev);
> >> +     kfree(dev);
> >
> > No, this is wrong, the memory will be freed in w1_master_release(),
> > right?  It is not freed here, sorry, this patch is incorrect.
> >
> Yeah, correct but the following change is correct no?
> 
>  int w1_add_master_device(struct w1_bus_master *master)
> @@ -148,7 +149,7 @@ int w1_add_master_device(struct w1_bus_master *master)
>                &w1_master_driver, &w1_master_device);
>        if (!dev) {
>                mutex_unlock(&w1_mlock);
> -               return -ENOMEM;
> +               return -ENODEV;

Possibly, care to resend it in a format that explains it and allows it
to be applied?

thanks,

greg k-h

  reply	other threads:[~2012-06-21 14:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-17 16:17 [PATCH] drivers/w1: free the w1_master at w1_free_dev and return a correct return value Devendra Naga
2012-06-20  8:06 ` Evgeniy Polyakov
2012-06-20 12:57   ` devendra.aaru
2012-06-20 23:55 ` Greg Kroah-Hartman
2012-06-21  4:44   ` devendra.aaru
2012-06-21 14:39     ` Greg Kroah-Hartman [this message]
2012-06-23 18:26       ` devendra.aaru
2012-06-21  7:48   ` Evgeniy Polyakov

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=20120621143950.GA1818@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=devendra.aaru@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zbr@ioremap.net \
    /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