On Fri, Apr 24, 2026 at 6:48 PM Johan Hovold <[email protected]> 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. > > Note that root_device_register(), which also creates a link to the > module, cannot be used as the device is registered when parsing the > module parameters which happens before the module kobject has been set > up. > > Fixes: 81a054ce0b46 ("virtio-mmio: Devices parameter parsing") > Cc: [email protected] # 3.5 > Cc: Pawel Moll <[email protected]> > Signed-off-by: Johan Hovold <[email protected]> > --- > drivers/virtio/virtio_mmio.c | 20 ++++++++------------ > 1 file changed, 8 insertions(+), 12 deletions(-) > > diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c > index 595c2274fbb5..1b580de81e82 100644 > --- a/drivers/virtio/virtio_mmio.c > +++ b/drivers/virtio/virtio_mmio.c > @@ -662,9 +662,7 @@ static void virtio_mmio_remove(struct platform_device > *pdev) > > #if defined(CONFIG_VIRTIO_MMIO_CMDLINE_DEVICES) > > -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. Thanks

