All of lore.kernel.org
 help / color / mirror / Atom feed
From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	rafael.j.wysocki@intel.com, swboyd@chromium.org,
	linux-kernel@vger.kernel.org
Cc: linux-pm@vger.kernel.org,
	Abhishek Pandit-Subedi <abhishekpandit@chromium.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: [PATCH 1/1] kobject: Don't emit change events if not in sysfs
Date: Mon, 19 Oct 2020 15:32:57 -0700	[thread overview]
Message-ID: <20201019153232.1.I797f9874972a07fc381fe586b6748ce71c7b1fda@changeid> (raw)
In-Reply-To: <20201019223257.261223-1-abhishekpandit@chromium.org>

Add a check to make sure the kobj is created and in sysfs before sending
a change event notification. Otherwise, udev rules that depend on the
change notification may find that the path that changed doesn't actually
exist.

Fixes: a45aca510b73b7 (PM: sleep: core: Emit changed uevent on wakeup_sysfs_add/remove)
Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---

 lib/kobject_uevent.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 7998affa45d49a..f08197e907d5ce 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -473,6 +473,11 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
 	if (action == KOBJ_REMOVE)
 		kobj->state_remove_uevent_sent = 1;
 
+	if (action == KOBJ_CHANGE && !kobj->state_in_sysfs) {
+		pr_debug("kobject: can't emit KOBJ_CHANGE until in sysfs\n");
+		return -EINVAL;
+	}
+
 	pr_debug("kobject: '%s' (%p): %s\n",
 		 kobject_name(kobj), kobj, __func__);
 
-- 
2.29.0.rc1.297.gfa9743e501-goog


  reply	other threads:[~2020-10-19 22:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-19 22:32 [PATCH 0/1] kobject: Don't emit change events if not in sysfs Abhishek Pandit-Subedi
2020-10-19 22:32 ` Abhishek Pandit-Subedi [this message]
2020-10-20  5:57   ` [PATCH 1/1] " Greg Kroah-Hartman
2020-10-21  3:27     ` Abhishek Pandit-Subedi

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=20201019153232.1.I797f9874972a07fc381fe586b6748ce71c7b1fda@changeid \
    --to=abhishekpandit@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=swboyd@chromium.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.