linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael Büsch" <m@bues.ch>
To: arvindY <arvind.yadav.cs@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org
Subject: Re: [PATCH] ssb:: use put_device() if device_register fail
Date: Wed, 7 Mar 2018 18:38:58 +0100	[thread overview]
Message-ID: <20180307183858.63172de9@wiggum> (raw)
In-Reply-To: <5AA01E5E.8070002@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1173 bytes --]

On Wed, 7 Mar 2018 22:46:14 +0530
arvindY <arvind.yadav.cs@gmail.com> wrote:
> >> diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
> >> index 65420a9..c4449e0 100644
> >> --- a/drivers/ssb/main.c
> >> +++ b/drivers/ssb/main.c
> >> @@ -521,6 +521,7 @@ static int ssb_devices_register(struct ssb_bus *bus)
> >>   			ssb_err("Could not register %s\n", dev_name(dev));
> >>   			/* Set dev to NULL to not unregister
> >>   			 * dev on error unwinding. */
> >> +			put_device(dev);
> >>   			sdev->dev = NULL;
> >>   			kfree(devwrap);
> >>   			goto error;  
> >
> > I don't think this is correct.
> > The dev structure is allocated as part of devwrap, which is freed here.
> >
> > Why do you think we need put_device here?
> >  
> Yes this patch is not correct, We must not use kfree() after you called 
> device_register() (even
> if it was not successful!) -- see the comment for device_register().
> I will delete kfree() and send updated patch.


Is device_put() going to call ssb_release_dev() to free the structure?

Can you please elaborate on why device_put() must be used? The comment
is not really of any use here.

-- 
Michael

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-03-07 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 10:01 [PATCH] ssb:: use put_device() if device_register fail Arvind Yadav
2018-03-07 16:47 ` Michael Büsch
2018-03-07 17:16   ` arvindY
2018-03-07 17:38     ` Michael Büsch [this message]
2018-03-07 18:22       ` arvindY

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=20180307183858.63172de9@wiggum \
    --to=m@bues.ch \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@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 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).