From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AD1219AD5C; Wed, 7 May 2025 19:06:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746644802; cv=none; b=YCvn1/B6ZkFJxcmmHz2RYSqOmT/aSl54tgl9KWluq2r3Vii4da/40nrIWNAZRjlC7ttA7zBezQp4rU9piWm+9N2sk1aF8IQUlGu+2ProDz17UM62GRixPDxQ9o80PkunU2hBq8ODqHhgSnUK+veEvZsILhvhG3/HSMC7PP9XOL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746644802; c=relaxed/simple; bh=79hOpXos0puHfcnfixL1gNA3RxLOlN0q09tNuxtAkDU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V36f0GzJEkFVYtWAXtyoQIEA+JZr9m2pLLSwFYWXc3ahp7ovkW3wtgbu5e6/Hj1uU7sTwNbQ4bFPRf8S64O38eGWbYkyN7yIAIYOGDtp7NplPNtdCiOJcDCXOovqTgPEXNfXVCkyk7WElIoPWE0NUpKU7Lo1o/6DBkmIdJjUNFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LvH9BKGY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LvH9BKGY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09047C4CEE2; Wed, 7 May 2025 19:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1746644802; bh=79hOpXos0puHfcnfixL1gNA3RxLOlN0q09tNuxtAkDU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LvH9BKGYMU1shAFulabbohS6mJ3olBC23UKQfOu8Q5l06EYkwwTrnxmJWkhFGstKl IGUsJ7nMnXWn6cFB4MDf2iiX9/OZFP/G2O064MNpNMvuJGhg1kOJluWC52XmM/Nnea bDV5ysQgPtLOZIxs0p7eWhmLWgNy/tkEkx7EHSO8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rasmus Villemoes , Shyam Saini , Petr Pavlu , Sasha Levin Subject: [PATCH 6.12 162/164] drivers: base: handle module_kobject creation Date: Wed, 7 May 2025 20:40:47 +0200 Message-ID: <20250507183827.521463411@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250507183820.781599563@linuxfoundation.org> References: <20250507183820.781599563@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shyam Saini [ Upstream commit f95bbfe18512c5c018720468959edac056a17196 ] module_add_driver() relies on module_kset list for /sys/module//drivers directory creation. Since, commit 96a1a2412acba ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time") drivers which are initialized from subsys_initcall() or any other higher precedence initcall couldn't find the related kobject entry in the module_kset list because module_kset is not fully populated by the time module_add_driver() refers it. As a consequence, module_add_driver() returns early without calling make_driver_name(). Therefore, /sys/module//drivers is never created. Fix this issue by letting module_add_driver() handle module_kobject creation itself. Fixes: 96a1a2412acb ("kernel/params.c: defer most of param_sysfs_init() to late_initcall time") Cc: stable@vger.kernel.org # requires all other patches from the series Suggested-by: Rasmus Villemoes Signed-off-by: Shyam Saini Acked-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/20250227184930.34163-5-shyamsaini@linux.microsoft.com Signed-off-by: Petr Pavlu Signed-off-by: Sasha Levin --- drivers/base/module.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/base/module.c b/drivers/base/module.c index 5bc71bea883a0..218aaa0964552 100644 --- a/drivers/base/module.c +++ b/drivers/base/module.c @@ -42,16 +42,13 @@ int module_add_driver(struct module *mod, const struct device_driver *drv) if (mod) mk = &mod->mkobj; else if (drv->mod_name) { - struct kobject *mkobj; - - /* Lookup built-in module entry in /sys/modules */ - mkobj = kset_find_obj(module_kset, drv->mod_name); - if (mkobj) { - mk = container_of(mkobj, struct module_kobject, kobj); + /* Lookup or create built-in module entry in /sys/modules */ + mk = lookup_or_create_module_kobject(drv->mod_name); + if (mk) { /* remember our module structure */ drv->p->mkobj = mk; - /* kset_find_obj took a reference */ - kobject_put(mkobj); + /* lookup_or_create_module_kobject took a reference */ + kobject_put(&mk->kobj); } } -- 2.39.5