lkml.org 
[lkml]   [2024]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] media: em28xx: return error on media_device_register() failure
Em Wed, 10 Jan 2024 09:39:58 -0800
Nikita Zhandarovich <n.zhandarovich@fintech.ru> escreveu:

> In an unlikely case of failure in media_device_register(), release
> resources and return the erroneous value. Otherwise, possible issues
> with registering the device will continue to be ignored.
>
> Found by Linux Verification Center (linuxtesting.org) with static
> analysis tool SVACE.
>
> Fixes: 37ecc7b1278f ("[media] em28xx: add media controller support")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
> ---
> drivers/media/usb/em28xx/em28xx-cards.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
> index 4d037c92af7c..dae731dfc569 100644
> --- a/drivers/media/usb/em28xx/em28xx-cards.c
> +++ b/drivers/media/usb/em28xx/em28xx-cards.c
> @@ -4095,6 +4095,8 @@ static int em28xx_usb_probe(struct usb_interface *intf,
> */
> #ifdef CONFIG_MEDIA_CONTROLLER
> retval = media_device_register(dev->media_dev);
> + if (retval)
> + goto err_free;

Not freeing resources here is intentional. See, the media controller
API is optional on this driver. It will just provide a way to identify
the device's topology, but the device is completely usable without
it.

Perhaps we need, instead, a patch documenting it, and preventing
static analysis tools to point it as an issue.

Thanks,
Mauro

\
 
 \ /
  Last update: 2024-01-11 07:49    [W:0.052 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site