diff mbox series

[v4,24/26] media: mc: Warn about drivers not releasing media device safely

Message ID 20240610100530.1107771-25-sakari.ailus@linux.intel.com (mailing list archive)
State New
Headers show
Series Media device lifetime management | expand

Commit Message

Sakari Ailus June 10, 2024, 10:05 a.m. UTC
The media device and associated resources may be released only when its
memory is no longer used. Warn about drivers not doing this, but instead
releasing the resources at driver unbind time.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/mc/mc-device.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Hans Verkuil June 17, 2024, 10:40 a.m. UTC | #1
On 10/06/2024 12:05, Sakari Ailus wrote:
> The media device and associated resources may be released only when its
> memory is no longer used. Warn about drivers not doing this, but instead
> releasing the resources at driver unbind time.

I think this should be folded in the previous patch.

> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>  drivers/media/mc/mc-device.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
> index 8cdd0d46e865..51836faa6d1a 100644
> --- a/drivers/media/mc/mc-device.c
> +++ b/drivers/media/mc/mc-device.c
> @@ -822,6 +822,9 @@ int __must_check __media_device_register(struct media_device *mdev,
>  		ref = kzalloc(sizeof(*mdev->devnode.ref), GFP_KERNEL);
>  		if (!ref)
>  			return -ENOMEM;
> +
> +		dev_warn(mdev->dev,
> +			 "Set mdev release op to safely release resources!\n");

I think this needs a comment as well. Basically stating the same as the
commit log message.

Regards,

	Hans

>  	}
>  
>  	/* Register the device node. */
Sakari Ailus June 17, 2024, 5:59 p.m. UTC | #2
Hi Hans,

On Mon, Jun 17, 2024 at 12:40:31PM +0200, Hans Verkuil wrote:
> On 10/06/2024 12:05, Sakari Ailus wrote:
> > The media device and associated resources may be released only when its
> > memory is no longer used. Warn about drivers not doing this, but instead
> > releasing the resources at driver unbind time.
> 
> I think this should be folded in the previous patch.
> 
> > 
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> >  drivers/media/mc/mc-device.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
> > index 8cdd0d46e865..51836faa6d1a 100644
> > --- a/drivers/media/mc/mc-device.c
> > +++ b/drivers/media/mc/mc-device.c
> > @@ -822,6 +822,9 @@ int __must_check __media_device_register(struct media_device *mdev,
> >  		ref = kzalloc(sizeof(*mdev->devnode.ref), GFP_KERNEL);
> >  		if (!ref)
> >  			return -ENOMEM;
> > +
> > +		dev_warn(mdev->dev,
> > +			 "Set mdev release op to safely release resources!\n");
> 
> I think this needs a comment as well. Basically stating the same as the
> commit log message.

I'll address these for v5.
diff mbox series

Patch

diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
index 8cdd0d46e865..51836faa6d1a 100644
--- a/drivers/media/mc/mc-device.c
+++ b/drivers/media/mc/mc-device.c
@@ -822,6 +822,9 @@  int __must_check __media_device_register(struct media_device *mdev,
 		ref = kzalloc(sizeof(*mdev->devnode.ref), GFP_KERNEL);
 		if (!ref)
 			return -ENOMEM;
+
+		dev_warn(mdev->dev,
+			 "Set mdev release op to safely release resources!\n");
 	}
 
 	/* Register the device node. */