public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: Shashank Balaji <shashank.mahadasyam@sony.com>
To: Gary Guo <gary@garyguo.net>
Cc: "Suzuki K Poulose" <suzuki.poulose@arm.com>,
	"James Clark" <james.clark@linaro.org>,
	"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	"Maxime Coquelin" <mcoquelin.stm32@gmail.com>,
	"Alexandre Torgue" <alexandre.torgue@foss.st.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Richard Cochran" <richardcochran@gmail.com>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Luis Chamberlain" <mcgrof@kernel.org>,
	"Petr Pavlu" <petr.pavlu@suse.com>,
	"Daniel Gomez" <da.gomez@kernel.org>,
	"Sami Tolvanen" <samitolvanen@google.com>,
	"Aaron Tomlin" <atomlin@atomlin.com>,
	"Mike Leach" <mike.leach@arm.com>, "Leo Yan" <leo.yan@arm.com>,
	"Rahul Bukte" <rahul.bukte@sony.com>,
	linux-kernel@vger.kernel.org, coresight@lists.linaro.org,
	linux-arm-kernel@lists.infradead.org,
	driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,
	linux-doc@vger.kernel.org,
	"Daniel Palmer" <daniel.palmer@sony.com>,
	"Tim Bird" <tim.bird@sony.com>,
	linux-modules@vger.kernel.org
Subject: Re: [PATCH v4 1/4] kernel: param: initialize module_kset before do_initcalls()
Date: Tue, 28 Apr 2026 09:37:12 +0900	[thread overview]
Message-ID: <afABOMT_s9DvF6NY@JPC00244420> (raw)
In-Reply-To: <DI3Z28IZZOT9.349TTWNN9VDMB@garyguo.net>

Hi Gary,

On Mon, Apr 27, 2026 at 02:29:55PM +0100, Gary Guo wrote:
> On Mon Apr 27, 2026 at 3:41 AM BST, Shashank Balaji wrote:
> > module_kset is initialized in param_sysfs_init(), a subsys_initcall. A number
> > of platform drivers register themselves prior to subsys_initcalls
> > (tegra194_cbb_driver registers in a pure_initcall, for example). With an
> > upcoming patch ("driver core: platform: set mod_name in driver registration")
> > that sets their mod_name in struct device_driver, lookup_or_create_module_kobject()
> > will be called for those drivers, which calls kset_find_obj(module_kset, mod_name).
> > This causes a null deref because module_kset isn't alive yet.
> >
> > Fix this by initializing module_kset in do_basic_setup() before do_initcalls().
> > Modernize the pr_warn while we're at it.
> >
> > Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Suggested-by: Gary Guo <gary@garyguo.net>
> 
> I didn't suggest this change :)
> 
> I suggested `pure_initcall`, which is just a one line change.

Oops, sorry about the misattribution.

> diff --git a/kernel/params.c b/kernel/params.c
> index 74d620bc2521..ac088d4b09a9 100644
> --- a/kernel/params.c
> +++ b/kernel/params.c
> @@ -957,7 +957,7 @@ static int __init param_sysfs_init(void)
>  
>  	return 0;
>  }
> -subsys_initcall(param_sysfs_init);
> +pure_initcall(param_sysfs_init);
>  
>  /*
>   * param_sysfs_builtin_init - add sysfs version and parameter
> 
> pure_initcall is level 0 so it happens before all other init calls. Does it not
> work?

tegra194_cbb_driver registers itself in a pure_initcall too. We wouldn't
want the ordering of its registration and module_kset init to be link order
dependent.

Thanks,
Shashank

  reply	other threads:[~2026-04-28  0:37 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21  6:02 [PATCH v2 0/2] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-21  6:02 ` [PATCH v2 1/2] kernel: param: handle NULL module_kset in lookup_or_create_module_kobject() Shashank Balaji
2026-04-21  6:27   ` Greg Kroah-Hartman
2026-04-21 14:59     ` Shashank Balaji
2026-04-21 15:20       ` Greg Kroah-Hartman
2026-04-21  6:02 ` [PATCH v2 2/2] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-21  6:24   ` Greg Kroah-Hartman
2026-04-22  9:49 ` [PATCH v3 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-22  9:49   ` [PATCH v3 1/4] kernel: param: initialize module_kset on-demand Shashank Balaji
2026-04-24  9:16     ` Shashank Balaji
2026-04-24 19:26     ` Gary Guo
2026-04-22  9:49   ` [PATCH v3 2/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-04-22  9:49   ` [PATCH v3 3/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-22  9:49   ` [PATCH v3 4/4] docs: driver-api: add mod_name argument to __platform_register_drivers() Shashank Balaji
2026-04-22 11:27     ` Greg Kroah-Hartman
2026-04-27  2:41   ` [PATCH v4 0/4] Enable sysfs module symlink for more built-in drivers Shashank Balaji
2026-04-27  2:41     ` [PATCH v4 1/4] kernel: param: initialize module_kset before do_initcalls() Shashank Balaji
2026-04-27 13:29       ` Gary Guo
2026-04-28  0:37         ` Shashank Balaji [this message]
2026-04-27  2:41     ` [PATCH v4 2/4] coresight: pass THIS_MODULE implicitly through a macro Shashank Balaji
2026-04-27 10:49       ` Leo Yan
2026-04-27  2:41     ` [PATCH v4 3/4] driver core: platform: set mod_name in driver registration Shashank Balaji
2026-04-27  2:41     ` [PATCH v4 4/4] docs: driver-api: add mod_name argument to __platform_register_drivers() Shashank Balaji

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=afABOMT_s9DvF6NY@JPC00244420 \
    --to=shashank.mahadasyam@sony.com \
    --cc=a.hindborg@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=aliceryhl@google.com \
    --cc=atomlin@atomlin.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=corbet@lwn.net \
    --cc=coresight@lists.linaro.org \
    --cc=da.gomez@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.palmer@sony.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=james.clark@linaro.org \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=mike.leach@arm.com \
    --cc=ojeda@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=rafael@kernel.org \
    --cc=rahul.bukte@sony.com \
    --cc=richardcochran@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=skhan@linuxfoundation.org \
    --cc=suzuki.poulose@arm.com \
    --cc=tim.bird@sony.com \
    --cc=tmgross@umich.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox