From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI and sysfs fixes for 2.5.74
Date: Thu, 3 Jul 2003 19:09:14 -0700 [thread overview]
Message-ID: <1057284554141@kroah.com> (raw)
In-Reply-To: <10572845542321@kroah.com>
ChangeSet 1.1372, 2003/07/03 16:28:49-07:00, greg@kroah.com
[PATCH] SYSFS: add module referencing to sysfs attribute files.
fs/sysfs/file.c | 9 +++++++++
include/linux/device.h | 11 ++++++-----
include/linux/sysfs.h | 2 ++
3 files changed, 17 insertions(+), 5 deletions(-)
diff -Nru a/fs/sysfs/file.c b/fs/sysfs/file.c
--- a/fs/sysfs/file.c Thu Jul 3 18:16:03 2003
+++ b/fs/sysfs/file.c Thu Jul 3 18:16:03 2003
@@ -247,6 +247,12 @@
if (!kobj || !attr)
goto Einval;
+ /* Grab the module reference for this attribute if we have one */
+ if (!try_module_get(attr->owner)) {
+ error = -ENODEV;
+ goto Done;
+ }
+
/* if the kobject has no ktype, then we assume that it is a subsystem
* itself, and use ops for it.
*/
@@ -300,6 +306,7 @@
goto Done;
Eaccess:
error = -EACCES;
+ module_put(attr->owner);
Done:
if (error && kobj)
kobject_put(kobj);
@@ -314,10 +321,12 @@
static int sysfs_release(struct inode * inode, struct file * filp)
{
struct kobject * kobj = filp->f_dentry->d_parent->d_fsdata;
+ struct attribute * attr = filp->f_dentry->d_fsdata;
struct sysfs_buffer * buffer = filp->private_data;
if (kobj)
kobject_put(kobj);
+ module_put(attr->owner);
if (buffer) {
if (buffer->page)
diff -Nru a/include/linux/device.h b/include/linux/device.h
--- a/include/linux/device.h Thu Jul 3 18:16:03 2003
+++ b/include/linux/device.h Thu Jul 3 18:16:03 2003
@@ -18,6 +18,7 @@
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/ioport.h>
+#include <linux/module.h>
#include <asm/semaphore.h>
#include <asm/atomic.h>
@@ -95,7 +96,7 @@
#define BUS_ATTR(_name,_mode,_show,_store) \
struct bus_attribute bus_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
.show = _show, \
.store = _store, \
};
@@ -136,7 +137,7 @@
#define DRIVER_ATTR(_name,_mode,_show,_store) \
struct driver_attribute driver_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
.show = _show, \
.store = _store, \
};
@@ -176,7 +177,7 @@
#define CLASS_ATTR(_name,_mode,_show,_store) \
struct class_attribute class_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
.show = _show, \
.store = _store, \
};
@@ -226,7 +227,7 @@
#define CLASS_DEVICE_ATTR(_name,_mode,_show,_store) \
struct class_device_attribute class_device_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
.show = _show, \
.store = _store, \
};
@@ -324,7 +325,7 @@
#define DEVICE_ATTR(_name,_mode,_show,_store) \
struct device_attribute dev_attr_##_name = { \
- .attr = {.name = __stringify(_name), .mode = _mode }, \
+ .attr = {.name = __stringify(_name), .mode = _mode, .owner = THIS_MODULE }, \
.show = _show, \
.store = _store, \
};
diff -Nru a/include/linux/sysfs.h b/include/linux/sysfs.h
--- a/include/linux/sysfs.h Thu Jul 3 18:16:03 2003
+++ b/include/linux/sysfs.h Thu Jul 3 18:16:03 2003
@@ -10,9 +10,11 @@
#define _SYSFS_H_
struct kobject;
+struct module;
struct attribute {
char * name;
+ struct module * owner;
mode_t mode;
};
next prev parent reply other threads:[~2003-07-04 1:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-04 2:06 [BK PATCH] PCI and sysfs fixes for 2.5.73 Greg KH
2003-07-04 2:09 ` [PATCH] PCI and sysfs fixes for 2.5.74 Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH [this message]
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 2:09 ` Greg KH
2003-07-04 6:52 ` [BK PATCH] PCI and sysfs fixes for 2.5.73 Dan Aloni
2003-07-04 17:05 ` 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=1057284554141@kroah.com \
--to=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 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.