Re: [PATCH v3 9/9] kobject: Require explicit initialization of struct kobj_type::release
From: Ian Rogers
Date: Thu Nov 19 2026 - 00:46:15 EST
On Wed, Nov 18, 2026 at 1:11 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> On Sun Nov 8, 2026 at 11:39 PM CET, Ian Rogers wrote:
> > static const struct kobj_type cpuregs_kobj_type = {
> > + /*
> > + * Pre-existing: info->kobj is embedded in per-CPU cpu_data;
> > + * cpuid_cpu_offline() only calls kobject_del().
> > + */
>
> All of these comments carry a “Pre-existing:” prefix, but that doesn’t
> distinguish cases with broken lifetime management from those where the storage
> remains valid despite the API misuse.
>
> For example:
>
> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > index ab14079d1c42..0847134a1391 100644
> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xcp.c
> > @@ -797,6 +797,11 @@ static const struct sysfs_ops xcp_cfg_res_sysfs_ops = {
> > };
> >
> > static const struct kobj_type xcp_cfg_res_sysfs_ktype = {
> > + /*
> > + * Pre-existing: xcp_res is embedded in struct amdgpu_xcp_cfg
> > + * rather than freed individually by kobject_put().
> > + */
> > + .release = NULL,
>
> Being embedded in another structure doesn't explain what guarantees that the
> enclosing allocation outlives the kobject’s final cleanup.
>
> Could you please drop the “Pre-existing:” prefix and make that distinction
> explicit? For broken cases, describe the lifetime problem and mark it as needing
> a follow-up fix. For cases where the lifetime is safe, explain what guarantees
> that safety, while acknowledging that omitting release() still violates the
> documented API contract.
>
> Also, do you plan to follow up on those cases?
Makes complete sense, thanks Danilo!
Auditing all 17 files in patch 9 with that distinction in mind:
- Only 3 built-in sites (arm64 cpuinfo, ACPI hotplug profiles, and
s390 sclp_mem) have backing storage that genuinely remains valid for
the lifetime of the kernel.
- The other 14 files either free/zero an enclosing dynamic or devm
allocation without waiting for final kobject cleanup, or are tristate
modules that unregister static kobjects/ksets on module_exit and can
unmap module memory before delayed cleanup finishes.
I've dropped the "Pre-existing:" prefix, documented the specific
guarantee or FIXME lifetime hazard at each site in v4, and yes, I plan
to send follow-up fixes to the respective subsystems once __must_init
is in place.
Thanks,
Ian
> Thanks,
> Danilo
>