public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* get_device in device_create_file
@ 2006-08-01 20:25 Pete Zaitcev
  2006-08-02  1:13 ` Dmitry Torokhov
  2006-08-03  7:52 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Pete Zaitcev @ 2006-08-01 20:25 UTC (permalink / raw)
  To: greg; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-03  7:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-01 20:25 get_device in device_create_file Pete Zaitcev
2006-08-02  1:13 ` Dmitry Torokhov
2006-08-02 21:49   ` Pete Zaitcev
2006-08-03  7:52 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox