Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp9352757imu; Wed, 5 Dec 2018 03:28:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/UPlKcFw+AyD1j37b+sKUZLJHnIJFkk3FWDh/xzV355I2WMEtU0LkXNLFHHPMlnraNBFOz6 X-Received: by 2002:a17:902:a40f:: with SMTP id p15mr24378415plq.286.1544009339808; Wed, 05 Dec 2018 03:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544009339; cv=none; d=google.com; s=arc-20160816; b=HJtoxhx6PeZpxXxRAhbeGPzoocCSAeQQwot/VlUhrS1Yx+HeNUiTiAfAPs6Z6ahT7m MQ/56hIKIZkg9n01bEzM1wV40mhN1xRhlBlijZ02vGxznLhx1pzEA3a3YZKP5AznQTa5 ob7le1viuBXc96N/HweXYY+O/GSxI8/UIlAM2yQFrd4K9Ey1LBTWtlpISI9hH9nriVDj +EnANS8d+35Tzt2xF/8MYUh7Esqfps46lZOWF782H7W2kbLv/+m0e6L4DS27IPdjZYlJ CKK31atd3BvJbQSAlEN9cfme40YrJ8Kf/Kzkkk+w1exAvKrzL2i3bPoAbinonnEnynNP NWrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+4gkxmL4JQ6Pf/pljdJ8vi9h/ZXWn+MziXHbnPGjiCU=; b=WrJEUEmzEH/JQGeC5TY6+qnA3T+FjzsfRAN+jQPv4e3mlsKcWKLt2pCXzvJDCN5AIc 4ilhOez3uax4z8oNjpacKWCJyNMtO/rt360RQzqaU9uWING9VyAeeUBjvFx8g3F7AxO/ PN61O1ov9fITBG/iVGDG1bmitP/G2fudbLXUy1DpIBvww7/mVpX/vgSjrBsMeLRviA9t Eq1+hRx3iz1Jon/bWjYBOAx6KH5g7dqq5otD6yFTwHYbSDHL0vK02l/AOsnvHKr3f6cL ExuiiyebhemEI8eO+1UUM5+fYk7qFAeXhSGEJkaIOaiN3mBwZ6PkKcs6fmp2OnvNQER8 /Cgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q5si18327107pgk.46.2018.12.05.03.28.44; Wed, 05 Dec 2018 03:28:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727620AbeLEL15 (ORCPT + 99 others); Wed, 5 Dec 2018 06:27:57 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53539 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbeLEL1y (ORCPT ); Wed, 5 Dec 2018 06:27:54 -0500 Received: by mail-wm1-f68.google.com with SMTP id y1so12797839wmi.3 for ; Wed, 05 Dec 2018 03:27:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+4gkxmL4JQ6Pf/pljdJ8vi9h/ZXWn+MziXHbnPGjiCU=; b=uO2BjA1vC7fe4CFZN+R041KpiWW58HK0CLcXVsVR3mPOO20Jw2IoWxzhSxRQ/ahDnd PHKZDi6jNLiLfWkPiQAdIBHLj1+0Q39wYq4E4lLmT63mV98SIqDlbA579dPhhF0uh4eV W6+bdTwSXNxUCY0P9+03VkdhDP5WJixxEMRCFJ/yAsc11o7yW5Fm8DnC78ndnQR2jilL OTCuc1xq0t1iB9F4Db/CPjySM8ro8ne3FhY+D+xM81C6G+mPgeJumsnphdR04A4HyLyP 9BusO+kCBZBk94y0UQ/vDmc3Ts6dx/7JtHQgZ51Sf4uTZBZqjqmv8XRqcWcEjRUG5PG/ 5uVQ== X-Gm-Message-State: AA+aEWZg0OFXUxa0rf6DqKF74ISFoSLacbHz+4IyGH06W7c+Qd281W2k 3l6KSUhOtWJWYaNc+kD1CbdVBA== X-Received: by 2002:a1c:3a8d:: with SMTP id h135-v6mr15514901wma.92.1544009272305; Wed, 05 Dec 2018 03:27:52 -0800 (PST) Received: from alatyr.usersys.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id d2sm14535027wrs.97.2018.12.05.03.27.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Dec 2018 03:27:51 -0800 (PST) From: Peter Rajnoha To: gregkh@linuxfoundation.org, rafael@kernel.org, jeyu@kernel.org, linux-kernel@vger.kernel.org Cc: msekleta@redhat.com, Peter Rajnoha Subject: [PATCH 1/2] kobject: return error code if writing /sys/.../uevent fails Date: Wed, 5 Dec 2018 12:27:44 +0100 Message-Id: <20181205112745.12276-2-prajnoha@redhat.com> In-Reply-To: <20181205112745.12276-1-prajnoha@redhat.com> References: <20181205112745.12276-1-prajnoha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/base/bus.c | 12 ++++++++---- drivers/base/core.c | 8 +++++++- kernel/module.c | 6 ++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 8bfd27ec73d6..b886b15cb53b 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -611,8 +611,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); @@ -828,8 +830,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); diff --git a/drivers/base/core.c b/drivers/base/core.c index ed145fbfeddf..92faafd03caf 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1074,8 +1074,14 @@ static ssize_t uevent_show(struct device *dev, struct device_attribute *attr, 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; } diff --git a/kernel/module.c b/kernel/module.c index 49a405891587..0812a7f80fa7 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1207,8 +1207,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 = -- 2.19.2