From 31da70434d6369ca0e3e51ea13e86b9e91dba534 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 14 Apr 2010 19:08:40 +0000 Subject: [PATCH] Fixed crash on read-only attributes after manual chmod on them. Reported by Mehmet Ali Cer git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1616 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_sysfs.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index d8b7d8461..4ecfc8100 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -485,7 +485,10 @@ static ssize_t scst_tgt_attr_store(struct kobject *kobj, kobj_attr = container_of(attr, struct kobj_attribute, attr); - res = kobj_attr->store(kobj, kobj_attr, buf, count); + if (kobj_attr->store) + res = kobj_attr->store(kobj, kobj_attr, buf, count); + else + res = -EIO; up_read(&tgt->tgt_attr_rwsem); @@ -1146,7 +1149,10 @@ static ssize_t scst_dev_attr_store(struct kobject *kobj, struct attribute *attr, kobj_attr = container_of(attr, struct kobj_attribute, attr); - res = kobj_attr->store(kobj, kobj_attr, buf, count); + if (kobj_attr->store) + res = kobj_attr->store(kobj, kobj_attr, buf, count); + else + res = -EIO; up_read(&dev->dev_attr_rwsem); @@ -1365,7 +1371,10 @@ static ssize_t scst_sess_attr_store(struct kobject *kobj, struct attribute *attr kobj_attr = container_of(attr, struct kobj_attribute, attr); - res = kobj_attr->store(kobj, kobj_attr, buf, count); + if (kobj_attr->store) + res = kobj_attr->store(kobj, kobj_attr, buf, count); + else + res = -EIO; up_read(&sess->sess_attr_rwsem); @@ -3314,7 +3323,10 @@ static ssize_t scst_store(struct kobject *kobj, struct attribute *attr, struct kobj_attribute *kobj_attr; kobj_attr = container_of(attr, struct kobj_attribute, attr); - return kobj_attr->store(kobj, kobj_attr, buf, count); + if (kobj_attr->store) + return kobj_attr->store(kobj, kobj_attr, buf, count); + else + return -EIO; } struct sysfs_ops scst_sysfs_ops = {