[lkml]   [2006]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subjectget_device in device_create_file
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
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2006-08-01 22:29    [W:0.049 / U:2.224 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site