[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 6/9] xen/sys-hypervisor: Add release callback to hyp_sysfs_kobj_type
- To: Juergen Gross <jgross@xxxxxxxx>
- From: Ian Rogers <irogers@xxxxxxxxxx>
- Date: Mon, 9 Nov 2026 14:29:55 -0800
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=S6J9qhUwfhfejNNDnNi/t39zME3R/+tshu3QmKCryWs=; fh=wGlH6owyz56d8d1N2OQXFqJvOmG9yCLb9N3kRuWzNAw=; b=V9yh4HM9n6IYJUMoMEv/oJ2tJuCDggLoWwtMCQCmHD3Kos4I4yzZNzcJ3fA+nsIimJ dD0nGjvdG/fe/szNVIhSTSBFnz1icO+NocJykursnMlcBatBIKxQHF7Tz5qAsnvulOKI f+R2SQlSJ1h2wU3iivS5HkkuIyFKCtDT+aZCG3OJ2LXhWoVhN7RhHBq52vT7jbd+1LB1 piaK18E0Jjf5oS3m72/GLbFZ//4LYF1sjECXrG27JvZpOxqJ5SlA9R8UIU3mteY3upfU Qv7H7Gv24gYy0M9Zu+W1jlXwICrELQJpPuFViKxNsc1957rgdVF9QeN3IW6rYIimSIG7 EgTg==; darn=lists.xenproject.org
- Arc-seal: i=1; a=rsa-sha256; t=1794263408; cv=none; d=google.com; s=arc-20260327; b=fJNbN6G5xcnBfxIQxqqqMpis0T+ySwGeWXET8uvybylMG1tOxjm+mRwrNGPXyc/X3g bp71xE1Ch7etqtijqzYoTgz1S4/ClklsR0PzD5VfhLpkf7APlazuapn8QOTB/IxRZj+W V/lOh1ZUo3b1fNdMW6Rmq7j51FPv0TC468xG0Nn3KnId2daqMXDmz1no4A4QRgEIpnV7 LI7xnacxXAWcby9L7o3sdgqHlUzXIYyY+ldB/5YFLErSxY3044AXx6T8aNhHRGC44HlI 0MkldA45SnCtD2fKsPxgXHVTJ+q/RavGr90Swj+EvVooNChxytlGZwWS8mrltL2j2kSA J9xw==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=google.com header.i="@google.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
- Cc: Danilo Krummrich <dakr@xxxxxxxxxx>, Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>, Kees Cook <kees@xxxxxxxxxx>, Miguel Ojeda <ojeda@xxxxxxxxxx>, "Rafael J . Wysocki" <rafael@xxxxxxxxxx>, Madhavan Srinivasan <maddy@xxxxxxxxxxxxx>, Michael Ellerman <mpe@xxxxxxxxxxxxxx>, Nicholas Piggin <npiggin@xxxxxxxxx>, Christophe Leroy <chleroy@xxxxxxxxxx>, Nayna Jain <nayna@xxxxxxxxxxxxx>, Srish Srinivasan <ssrish@xxxxxxxxxxxxx>, Mimi Zohar <zohar@xxxxxxxxxxxxx>, Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>, Rich Felker <dalias@xxxxxxxx>, John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Nathan Chancellor <nathan@xxxxxxxxxx>, Nick Desaulniers <ndesaulniers@xxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>, Zhongqiu Han <zhongqiu.han@xxxxxxxxxxxxxxxx>, Alexander Aring <aahringo@xxxxxxxxxx>, Felix Kuehling <felix.kuehling@xxxxxxx>, Christian König <christian.koenig@xxxxxxx>, Zhihao Cheng <chengzhihao1@xxxxxxxxxx>, Sumanth Korikkar <sumanthk@xxxxxxxxxxxxx>, Bill Wendling <morbo@xxxxxxxxxx>, Justin Stitt <justinstitt@xxxxxxxxxx>, driver-core@xxxxxxxxxxxxxxx, llvm@xxxxxxxxxxxxxxx, linux-hardening@xxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx, linux-doc@xxxxxxxxxxxxxxx, linux-acpi@xxxxxxxxxxxxxxx, linux-pm@xxxxxxxxxxxxxxx, linuxppc-dev@xxxxxxxxxxxxxxxx, linux-sh@xxxxxxxxxxxxxxx, linux-s390@xxxxxxxxxxxxxxx, gfs2@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-mtd@xxxxxxxxxxxxxxxxxxx, amd-gfx@xxxxxxxxxxxxxxxxxxxxx, dri-devel@xxxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
- Delivery-date: Mon, 09 Nov 2026 22:30:27 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Sun, Nov 8, 2026 at 10:56 PM Juergen Gross <jgross@xxxxxxxx> wrote:
>
> On 08.11.26 23:39, Ian Rogers wrote:
> > hypervisor_init() in drivers/base/hypervisor.c creates hypervisor_kobj
> > with kobject_create_and_add() (which allocates a dynamic kobject using
> > dynamic_kobj_ktype), and hypervisor_subsys_init() in
> > drivers/xen/sys-hypervisor.c then overwrites hypervisor_kobj->ktype with
> > &hyp_sysfs_kobj_type, which had no .release callback.
> >
> > Add hyp_sysfs_release() calling kfree(kobj) to preserve the dynamic
> > kobject release behavior.
> >
> > Fixes: cff7e81b3dd7 ("xen: add /sys/hypervisor support")
> > Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> > ---
> > drivers/xen/sys-hypervisor.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/xen/sys-hypervisor.c b/drivers/xen/sys-hypervisor.c
> > index 91923242a5ae..0e8a2cd69fd6 100644
> > --- a/drivers/xen/sys-hypervisor.c
> > +++ b/drivers/xen/sys-hypervisor.c
> > @@ -659,7 +659,13 @@ static const struct sysfs_ops hyp_sysfs_ops = {
> > .store = hyp_sysfs_store,
> > };
> >
> > +static void hyp_sysfs_release(struct kobject *kobj)
> > +{
> > + kfree(kobj);
> > +}
> > +
> > static const struct kobj_type hyp_sysfs_kobj_type = {
> > + .release = hyp_sysfs_release,
> > .sysfs_ops = &hyp_sysfs_ops,
> > };
> >
>
> Wouldn't it make sense to have a common function for just kfree(kobj)?
>
> In your series there are 3 instances of .release just doing kfree(kobj).
>
> In case this is not wanted or with using the suggested common .release
> helper you can add my
>
> Reviewed-by: Juergen Gross <jgross@xxxxxxxx>
Thanks Juergen!
lib/kobject.c already has a static dynamic_kobj_release() that does
this (and there are ~15 other places in the tree open-coding a static
kfree(kobj) release wrapper), so include/linux/kobject.h +
lib/kobject.c would be the natural home if we exported one.
I kept them as local static functions here for two reasons:
1. Patches 2/9, 3/9, and 6/9 carry Fixes: tags, and keeping the small
local callbacks avoids a dependency on a new driver-core export for
backports.
2. Since kobjects are normally embedded in a larger struct and freed via
container_of(), I wasn't sure whether Greg and Danilo would view an
exported kfree(kobj) release helper (especially alongside
__must_init) as an invitation for misuse on embedded kobjects.
Unless Greg or Danilo would like dynamic_kobj_release() (or similar)
exported now, I'll plan to keep the local callbacks for this series
and can send a follow-up cleanup for the tree-wide callers if
driver-core maintainers think a shared helper makes sense.
Thanks,
Ian
>
>
> Juergen
|