]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
kobject: return error code if writing /sys/.../uevent fails
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 5 Dec 2018 11:27:44 +0000 (12:27 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837664
[ Upstream commit df44b479654f62b478c18ee4d8bc4e9f897a9844 ]

Propagate error code back to userspace if writing the /sys/.../uevent
file fails. Before, the write operation always returned with success,
even if we failed to recognize the input string or if we failed to
generate the uevent itself.

With the error codes properly propagated back to userspace, we are
able to react in userspace accordingly by not assuming and awaiting
a uevent that is not delivered.

Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/base/bus.c
drivers/base/core.c
kernel/module.c

index 1cf1460f8c90c01ca6393a4916b6e977bd259c9c..3464c49dad0db99fbd04086fb7187ad023e88e87 100644 (file)
@@ -616,8 +616,10 @@ static void remove_probe_files(struct bus_type *bus)
 static ssize_t uevent_store(struct device_driver *drv, const char *buf,
                            size_t count)
 {
-       kobject_synth_uevent(&drv->p->kobj, buf, count);
-       return count;
+       int rc;
+
+       rc = kobject_synth_uevent(&drv->p->kobj, buf, count);
+       return rc ? rc : count;
 }
 static DRIVER_ATTR_WO(uevent);
 
@@ -833,8 +835,10 @@ static void klist_devices_put(struct klist_node *n)
 static ssize_t bus_uevent_store(struct bus_type *bus,
                                const char *buf, size_t count)
 {
-       kobject_synth_uevent(&bus->p->subsys.kobj, buf, count);
-       return count;
+       int rc;
+
+       rc = kobject_synth_uevent(&bus->p->subsys.kobj, buf, count);
+       return rc ? rc : count;
 }
 static BUS_ATTR(uevent, S_IWUSR, NULL, bus_uevent_store);
 
index bfd1650d0ff2538a350ab3d01a9cc01bf44e9d10..2aeeb4bb09b91e42116016b1f621fdd0a643b6a3 100644 (file)
@@ -1000,8 +1000,14 @@ out:
 static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
                            const char *buf, size_t count)
 {
-       if (kobject_synth_uevent(&dev->kobj, buf, count))
+       int rc;
+
+       rc = kobject_synth_uevent(&dev->kobj, buf, count);
+
+       if (rc) {
                dev_err(dev, "uevent: failed to send synthetic uevent\n");
+               return rc;
+       }
 
        return count;
 }
index 136066b8ef2a771a1bbcfc79f4b63432effe55d0..a2f97b1e1eaf0947ef21f6d94e01621b9e8dad83 100644 (file)
@@ -1209,8 +1209,10 @@ static ssize_t store_uevent(struct module_attribute *mattr,
                            struct module_kobject *mk,
                            const char *buffer, size_t count)
 {
-       kobject_synth_uevent(&mk->kobj, buffer, count);
-       return count;
+       int rc;
+
+       rc = kobject_synth_uevent(&mk->kobj, buffer, count);
+       return rc ? rc : count;
 }
 
 struct module_attribute module_uevent =