mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: greg@kroah.com
Cc: linux-kernel@vger.kernel.org
Subject: get_device in device_create_file
Date: Tue, 1 Aug 2006 13:25:09 -0700	[thread overview]
Message-ID: <20060801132509.27269013.zaitcev@redhat.com> (raw)

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.
Buf it not, and the caller has a reference, then the call to
get_device is redundant.

How is this supposed to work?

-- Pete

             reply	other threads:[~2006-08-01 20:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-01 20:25 Pete Zaitcev [this message]
2006-08-02  1:13 ` Dmitry Torokhov
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=20060801132509.27269013.zaitcev@redhat.com \
    --to=zaitcev@redhat.com \
    --cc=greg@kroah.com \
    --cc=linux-kernel@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

Powered by JetHome