Re: [PATCH] media: mali-c55: Fix NULL dev stream alert for tpg sub-device

From: Jacopo Mondi

Date: Tue Jan 13 2026 - 07:43:17 EST


Hi Sakari

On Tue, Jan 13, 2026 at 12:40:25PM +0200, Sakari Ailus wrote:
> Hi Jacopo,
>
> On Tue, Jan 13, 2026 at 09:55:10AM +0100, Jacopo Mondi wrote:
> > I wonder if v4l2_device_register_subdev() shouldn't WARN or if return
> > an error if sd->dev is not initialized. Laurent, Sakari: opinions ?
>
> I might even return an error but I wonder what would break. Perhaps indeed
> could start with a warning?

I would start with:

--- a/drivers/media/v4l2-core/v4l2-device.c
+++ b/drivers/media/v4l2-core/v4l2-device.c
@@ -117,6 +117,13 @@ int __v4l2_device_register_subdev(struct v4l2_device *v4l2_dev,
if (!v4l2_dev || !sd || sd->v4l2_dev || !sd->name[0])
return -EINVAL;

+ /*
+ * Initializing sd->dev is mandatory. Warn for now to give faulty
+ * drivers a bit of time to update before actually returning an error.
+ */
+ WARN_ON(!sd->dev);
+
/*
* The reason to acquire the module here is to avoid unloading
* a module of sub-device which is registered to a media

Would you like a patch ?

>
> --
> Sakari Ailus