Subject: Re: [PATCH] virtio-mmio: fix device release warning on module unload

From: Johan Hovold <[email-masked]>
Date: Mon, 27 Apr 2026 17:01:58 +0200

On Mon, Apr 27, 2026 at 12:16:47PM +0800, Jason Wang wrote:
> On Fri, Apr 24, 2026 at 6:48 PM Johan Hovold <[email-masked]> wrote:
> >
> > Driver core expects devices to be allocated dynamically and complains
> > loudly when a device that lacks a release function is freed.
> >
> > Use __root_device_register() to allocate and register the root device
> > instead of open coding using a static device.

> > -static struct device vm_cmdline_parent = {
> > -       .init_name = "virtio-mmio-cmdline",
> > -};
> > +static struct device *vm_cmdline_parent;
> 
> vm_cmdline_get() is the .get callback for the device module parameter.
> It is invoked when userspace reads
> /sys/module/virtio_mmio/parameters/device. This function uses
> vm_cmdline_parent unconditionally, without checking whether the device
> has been registered. This would cause NULL pointer dereference.

Indeed, Sashiko flagged this as well. Just sent a v2 here:

	https://lore.kernel.org/r/[email-masked]

Johan