All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@kernel.org>
To: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Cc: <linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] media: em28xx: return error on media_device_register() failure
Date: Thu, 11 Jan 2024 07:49:05 +0100	[thread overview]
Message-ID: <20240111074905.67d61b00@coco.lan> (raw)
In-Reply-To: <20240110173958.4544-1-n.zhandarovich@fintech.ru>

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

  parent reply	other threads:[~2024-01-11  6:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 17:39 [PATCH] media: em28xx: return error on media_device_register() failure Nikita Zhandarovich
2024-01-10 19:15 ` Christophe JAILLET
2024-01-11  6:49 ` Mauro Carvalho Chehab [this message]
2024-01-11 15:10   ` Nikita Zhandarovich
2024-01-11 17:40     ` Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240111074905.67d61b00@coco.lan \
    --to=mchehab@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=n.zhandarovich@fintech.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.