[PATCH v3 2/9] powerpc/secvar: Add missing kobject release callback to secvar_ktype

Srish Srinivasan ssrish at linux.ibm.com
Wed Nov 18 00:17:12 PST 2026


On 11/9/26 4:09 AM, Ian Rogers wrote:
> In add_var(), a struct kobject is dynamically allocated with
> kzalloc_obj() and initialized with secvar_ktype. If kobject_add() or
> sysfs_create_file() fails, kobject_put(kobj) is called to clean up.
> However, secvar_ktype does not define a .release callback, which results
> in a memory leak of kobj (and a pr_debug warning in kobject_cleanup()
> when CONFIG_DEBUG_KOBJECT_RELEASE is enabled).
>
> Provide a secvar_release() callback that calls kfree(kobj).
>
> Fixes: bd5d9c743d38 ("powerpc: expose secure variables to userspace via sysfs")
> Signed-off-by: Ian Rogers <irogers at google.com>


LGTM,
thank you!

Reviewed-by: Srish Srinivasan <ssrish at linux.ibm.com>


> ---
>   arch/powerpc/kernel/secvar-sysfs.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/arch/powerpc/kernel/secvar-sysfs.c b/arch/powerpc/kernel/secvar-sysfs.c
> index 395399bbab2c..f3f6ac25ea78 100644
> --- a/arch/powerpc/kernel/secvar-sysfs.c
> +++ b/arch/powerpc/kernel/secvar-sysfs.c
> @@ -126,7 +126,13 @@ static const struct attribute_group secvar_attr_group = {
>   };
>   __ATTRIBUTE_GROUPS(secvar_attr);
>   
> +static void secvar_release(struct kobject *kobj)
> +{
> +	kfree(kobj);
> +}
> +
>   static const struct kobj_type secvar_ktype = {
> +	.release	= secvar_release,
>   	.sysfs_ops	= &kobj_sysfs_ops,
>   	.default_groups = secvar_attr_groups,
>   };



More information about the linux-mtd mailing list