Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3825897pxu; Tue, 20 Oct 2020 01:12:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmntNEGsHJnRG4sWxQKgu6PzQPVngYjLjTjeNzm4y2zOBx8yfdSjupuDqwyzYl9cPAWvhu X-Received: by 2002:a05:6402:3184:: with SMTP id di4mr1611630edb.362.1603181520090; Tue, 20 Oct 2020 01:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603181520; cv=none; d=google.com; s=arc-20160816; b=E9Glez8GjC8oVFgF2R6uy+jvKi4Kx6sB3DiAR7V9SXEo/6TGU8EM1MmW+WemcdXyFP Mgt2zK9daca1VR54uAGcxeXvSl8Xt+Mci/EKAYw/YJkt+0hTXr/MhiD5jNItmP6Aj517 M+tp205t+CBq66PijULSRJVP1iMqFcagH6Yo4I/lxbSlvjsWa1rWhN8c+zU9agcCCEf2 sN3bY3YXCaV87dgn0vlRmC4WP8jdgU9Adr6lDmJwCXeuaqiynuATOcjK8kSRyIoV9vCm 0jl5PtTGrr9c7bDFg+4moC213OuEyGEWIvrZCuieoTi//7WfJkybwHNjyoWW+uFJ+9tJ 8zvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YRjo2HvYrN2YlB7PX+blFf8vNEJz+jYGbB/nTBk0Ba8=; b=zL0uAWGnsOTpfk4l0SUPwcr8ygASkpMGHMTwFiSPLxfbpHlPVg2WRuu9rPf4ycs5O5 pNzs7FyJt+pMVMqaB2ca8NMkOq0+z6Oc0ajHjy7e4eteCHewYHoVGGlzrpuCR7tKgWbE kVi2N2QxurESOJ4diPUazFiGyY7CWtSeBWNsxccZyZJDVuEEl9lk9WE+Oo2R15IG7+xU GN8PFpFcxn8NWX3SSh0ubcXhITiY0NxNKF7CkrA7GVXH2E+7IYbbpPXXnGkFTAY+VDJj Z6Y1CNBVHM8QAYZd6wwzKzD5mq7v3TKKqLjpizYSqvvGl7j4ekg6GZFIYsns88rn9wwI EA4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OC1dGuQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si695056edy.511.2020.10.20.01.11.38; Tue, 20 Oct 2020 01:12:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OC1dGuQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388209AbgJSWdJ (ORCPT + 99 others); Mon, 19 Oct 2020 18:33:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729840AbgJSWdG (ORCPT ); Mon, 19 Oct 2020 18:33:06 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C0ECC0613D0 for ; Mon, 19 Oct 2020 15:33:06 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id e10so852246pfj.1 for ; Mon, 19 Oct 2020 15:33:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YRjo2HvYrN2YlB7PX+blFf8vNEJz+jYGbB/nTBk0Ba8=; b=OC1dGuQQU6DMsWrKaHis4dloEGAs6n41NTtAe9LMiaBcJ2/K05WNyxvaq3h1OtI6TH Kb4YbJhU16bT6ftitK6musRNCmsn5BcYU4gPT30kNnP6dq+jIJtWlXQrmv3jVAeRMkPv 0L1pc3rfXNArykrq0o3ZFqtB7llzIqY/nSSsg= 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=YRjo2HvYrN2YlB7PX+blFf8vNEJz+jYGbB/nTBk0Ba8=; b=Vzxm9mnQwPdX72m82gF0xnEkxXdG+4lWjqv16AciU4qs4n9mlWD+G3jpgmwzzuNibH +mJu9nbPan0au5vFlPfOyGilCmqWY+Y0d9tWx2zoFQwqOK58SeFWWNSCQ12Sg5K5u9Ha UIDcTSzNp2lTH75ACmdxePEdv5VVEIx3dYF8eNkUUL/edDJHFIuyWHGfpyuDh1Au1nKh k6Ry0NX2dMCRzk+6ol5+PL8sAuVk5JXjoPy8zIKvafXh5Hm7np6BQKfO4S0yFZPAExr/ e/9qg/2l2Bi9esHMzuhTet8DT5BJrirTnyQialWxpp+wX68OOQuhgGHhju04lS3w+BJ0 halA== X-Gm-Message-State: AOAM533nhm97BIS/E3JRAo0hQc7JKBuBuQXr6NPX3mt2UxLk56Hc3psb hwKjC3HPuSNPf35nV9+K35DfNg== X-Received: by 2002:a63:f84c:: with SMTP id v12mr29801pgj.125.1603146786040; Mon, 19 Oct 2020 15:33:06 -0700 (PDT) Received: from apsdesk.mtv.corp.google.com ([2620:15c:202:1:7220:84ff:fe09:2b94]) by smtp.gmail.com with ESMTPSA id s20sm10897pfu.112.2020.10.19.15.33.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 15:33:05 -0700 (PDT) From: Abhishek Pandit-Subedi To: Greg Kroah-Hartman , rafael.j.wysocki@intel.com, swboyd@chromium.org, linux-kernel@vger.kernel.org Cc: linux-pm@vger.kernel.org, Abhishek Pandit-Subedi , "Rafael J. Wysocki" Subject: [PATCH 1/1] kobject: Don't emit change events if not in sysfs Date: Mon, 19 Oct 2020 15:32:57 -0700 Message-Id: <20201019153232.1.I797f9874972a07fc381fe586b6748ce71c7b1fda@changeid> X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog In-Reply-To: <20201019223257.261223-1-abhishekpandit@chromium.org> References: <20201019223257.261223-1-abhishekpandit@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 --- 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