From dtor_core@ameritech.net Fri Apr 29 07:06:44 2005 From: Dmitry Torokhov Subject: sysfs: (rest) if show/store is missing return -EIO Date: Fri, 29 Apr 2005 01:27:34 -0500 sysfs: fix the rest of the kernel so if an attribute doesn't implement show or store method read/write will return -EIO instead of 0 or -EINVAL or -EPERM. Signed-off-by: Dmitry Torokhov Signed-off-by: Greg Kroah-Hartman --- drivers/acpi/scan.c | 4 ++-- drivers/cpufreq/cpufreq.c | 4 ++-- drivers/firmware/edd.c | 2 +- drivers/firmware/efivars.c | 4 ++-- drivers/infiniband/core/sysfs.c | 2 +- kernel/params.c | 4 ++-- security/seclvl.c | 4 ++-- 7 files changed, 12 insertions(+), 12 deletions(-) --- gregkh-2.6.orig/drivers/cpufreq/cpufreq.c 2005-05-03 21:48:38.000000000 -0700 +++ gregkh-2.6/drivers/cpufreq/cpufreq.c 2005-05-03 22:05:21.000000000 -0700 @@ -521,7 +521,7 @@ policy = cpufreq_cpu_get(policy->cpu); if (!policy) return -EINVAL; - ret = fattr->show ? fattr->show(policy,buf) : 0; + ret = fattr->show ? fattr->show(policy,buf) : -EIO; cpufreq_cpu_put(policy); return ret; } @@ -535,7 +535,7 @@ policy = cpufreq_cpu_get(policy->cpu); if (!policy) return -EINVAL; - ret = fattr->store ? fattr->store(policy,buf,count) : 0; + ret = fattr->store ? fattr->store(policy,buf,count) : -EIO; cpufreq_cpu_put(policy); return ret; } --- gregkh-2.6.orig/drivers/firmware/efivars.c 2005-04-06 11:47:46.000000000 -0700 +++ gregkh-2.6/drivers/firmware/efivars.c 2005-05-03 22:05:21.000000000 -0700 @@ -352,7 +352,7 @@ { struct efivar_entry *var = to_efivar_entry(kobj); struct efivar_attribute *efivar_attr = to_efivar_attr(attr); - ssize_t ret = 0; + ssize_t ret = -EIO; if (!capable(CAP_SYS_ADMIN)) return -EACCES; @@ -368,7 +368,7 @@ { struct efivar_entry *var = to_efivar_entry(kobj); struct efivar_attribute *efivar_attr = to_efivar_attr(attr); - ssize_t ret = 0; + ssize_t ret = -EIO; if (!capable(CAP_SYS_ADMIN)) return -EACCES; --- gregkh-2.6.orig/kernel/params.c 2005-04-20 21:25:11.000000000 -0700 +++ gregkh-2.6/kernel/params.c 2005-05-03 22:05:21.000000000 -0700 @@ -629,7 +629,7 @@ mk = to_module_kobject(kobj); if (!attribute->show) - return -EPERM; + return -EIO; if (!try_module_get(mk->mod)) return -ENODEV; @@ -653,7 +653,7 @@ mk = to_module_kobject(kobj); if (!attribute->store) - return -EPERM; + return -EIO; if (!try_module_get(mk->mod)) return -ENODEV; --- gregkh-2.6.orig/drivers/infiniband/core/sysfs.c 2005-05-03 21:48:39.000000000 -0700 +++ gregkh-2.6/drivers/infiniband/core/sysfs.c 2005-05-03 22:05:21.000000000 -0700 @@ -71,7 +71,7 @@ struct ib_port *p = container_of(kobj, struct ib_port, kobj); if (!port_attr->show) - return 0; + return -EIO; return port_attr->show(p, port_attr, buf); } --- gregkh-2.6.orig/security/seclvl.c 2005-04-06 11:47:48.000000000 -0700 +++ gregkh-2.6/security/seclvl.c 2005-05-03 22:05:21.000000000 -0700 @@ -155,7 +155,7 @@ struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); struct seclvl_attribute *attribute = container_of(attr, struct seclvl_attribute, attr); - return (attribute->store ? attribute->store(obj, buf, len) : 0); + return attribute->store ? attribute->store(obj, buf, len) : -EIO; } static ssize_t @@ -164,7 +164,7 @@ struct seclvl_obj *obj = container_of(kobj, struct seclvl_obj, kobj); struct seclvl_attribute *attribute = container_of(attr, struct seclvl_attribute, attr); - return (attribute->show ? attribute->show(obj, buf) : 0); + return attribute->show ? attribute->show(obj, buf) : -EIO; } /** --- gregkh-2.6.orig/drivers/acpi/scan.c 2005-05-03 21:48:38.000000000 -0700 +++ gregkh-2.6/drivers/acpi/scan.c 2005-05-03 22:05:21.000000000 -0700 @@ -65,14 +65,14 @@ { struct acpi_device *device = to_acpi_device(kobj); struct acpi_device_attribute *attribute = to_handle_attr(attr); - return attribute->show ? attribute->show(device, buf) : 0; + return attribute->show ? attribute->show(device, buf) : -EIO; } static ssize_t acpi_device_attr_store(struct kobject *kobj, struct attribute *attr, const char *buf, size_t len) { struct acpi_device *device = to_acpi_device(kobj); struct acpi_device_attribute *attribute = to_handle_attr(attr); - return attribute->store ? attribute->store(device, buf, len) : len; + return attribute->store ? attribute->store(device, buf, len) : -EIO; } static struct sysfs_ops acpi_device_sysfs_ops = { --- gregkh-2.6.orig/drivers/firmware/edd.c 2005-03-01 23:37:55.000000000 -0800 +++ gregkh-2.6/drivers/firmware/edd.c 2005-05-03 22:05:21.000000000 -0700 @@ -115,7 +115,7 @@ { struct edd_device *dev = to_edd_device(kobj); struct edd_attribute *edd_attr = to_edd_attr(attr); - ssize_t ret = 0; + ssize_t ret = -EIO; if (edd_attr->show) ret = edd_attr->show(dev, buf);