From: Dmitry Torokhov <dtor@insightbb.com>
To: Pete Zaitcev <zaitcev@redhat.com>
Cc: greg@kroah.com, linux-kernel@vger.kernel.org
Subject: Re: get_device in device_create_file
Date: Tue, 1 Aug 2006 21:13:05 -0400 [thread overview]
Message-ID: <200608012113.06191.dtor@insightbb.com> (raw)
In-Reply-To: <20060801132509.27269013.zaitcev@redhat.com>
On Tuesday 01 August 2006 16:25, Pete Zaitcev wrote:
> Hi, Greg:
>
> This code makes no sense to me:
>
> > int device_create_file(struct device * dev, struct device_attribute * attr)
> > {
> > int error = 0;
> > if (get_device(dev)) {
> > error = sysfs_create_file(&dev->kobj, &attr->attr);
> > put_device(dev);
> > }
> > return error;
> > }
>
> If the struct device *dev, and its presumably enclosing structure,
> can be freed by a different CPU (or pre-empt), then get_device
> does not protect it. It can be freed before get_device is reached.
*nod*
> Buf it not, and the caller has a reference, then the call to
> get_device is redundant.
>
Yes it is. There are few of redundant gets and puts sprinkled around
in the driver core, but the last time I mentioned that Greg was not
quite ready to get rid of them ;)
--
Dmitry
next prev parent reply other threads:[~2006-08-02 1:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-01 20:25 get_device in device_create_file Pete Zaitcev
2006-08-02 1:13 ` Dmitry Torokhov [this message]
2006-08-02 21:49 ` Pete Zaitcev
2006-08-03 7:52 ` Greg KH
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=200608012113.06191.dtor@insightbb.com \
--to=dtor@insightbb.com \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zaitcev@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.