All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map
@ 2022-03-24  8:17 Hangyu Hua
  2022-03-24 14:09 ` Laurent Pinchart
  2022-03-24 17:17 ` Ricardo Ribalda
  0 siblings, 2 replies; 4+ messages in thread
From: Hangyu Hua @ 2022-03-24  8:17 UTC (permalink / raw)
  To: laurent.pinchart, mchehab; +Cc: linux-media, linux-kernel, Hangyu Hua

map->name needs to be freed when uvc_ioctl_ctrl_map fails.

Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 drivers/media/usb/uvc/uvc_v4l2.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 711556d13d03..e46a2f3b06cb 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -93,6 +93,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
 
 	kfree(map->menu_info);
 free_map:
+	kfree(map->name);
 	kfree(map);
 
 	return ret;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map
  2022-03-24  8:17 [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map Hangyu Hua
@ 2022-03-24 14:09 ` Laurent Pinchart
  2022-03-24 17:17 ` Ricardo Ribalda
  1 sibling, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2022-03-24 14:09 UTC (permalink / raw)
  To: Hangyu Hua; +Cc: mchehab, linux-media, linux-kernel

Hi Hangyu,

Thank you for the patch.

On Thu, Mar 24, 2022 at 04:17:18PM +0800, Hangyu Hua wrote:
> map->name needs to be freed when uvc_ioctl_ctrl_map fails.
> 
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
>  drivers/media/usb/uvc/uvc_v4l2.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 711556d13d03..e46a2f3b06cb 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -93,6 +93,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
>  
>  	kfree(map->menu_info);
>  free_map:
> +	kfree(map->name);

The memory is actually freed in uvc_ctrl_cleanup_mappings() in the
non-error case. I think we could improve this by avoiding the kmemdup()
in this function, and duplicating the name in __uvc_ctrl_add_mapping()
instead. What do you think ?

>  	kfree(map);
>  
>  	return ret;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map
  2022-03-24  8:17 [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map Hangyu Hua
  2022-03-24 14:09 ` Laurent Pinchart
@ 2022-03-24 17:17 ` Ricardo Ribalda
  2022-03-24 20:07   ` Laurent Pinchart
  1 sibling, 1 reply; 4+ messages in thread
From: Ricardo Ribalda @ 2022-03-24 17:17 UTC (permalink / raw)
  To: Hangyu Hua; +Cc: laurent.pinchart, mchehab, linux-media, linux-kernel

Isnt it a dupe of:
https://patchwork.linuxtv.org/project/linux-media/patch/20211008120914.69175-1-ribalda@chromium.org/
?

On Thu, 24 Mar 2022 at 18:13, Hangyu Hua <hbh25y@gmail.com> wrote:
>
> map->name needs to be freed when uvc_ioctl_ctrl_map fails.
>
> Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> ---
>  drivers/media/usb/uvc/uvc_v4l2.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> index 711556d13d03..e46a2f3b06cb 100644
> --- a/drivers/media/usb/uvc/uvc_v4l2.c
> +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> @@ -93,6 +93,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
>
>         kfree(map->menu_info);
>  free_map:
> +       kfree(map->name);
>         kfree(map);
>
>         return ret;
> --
> 2.25.1
>


-- 
Ricardo Ribalda

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map
  2022-03-24 17:17 ` Ricardo Ribalda
@ 2022-03-24 20:07   ` Laurent Pinchart
  0 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2022-03-24 20:07 UTC (permalink / raw)
  To: Ricardo Ribalda; +Cc: Hangyu Hua, mchehab, linux-media, linux-kernel

On Thu, Mar 24, 2022 at 06:17:18PM +0100, Ricardo Ribalda wrote:
> Isnt it a dupe of:
> https://patchwork.linuxtv.org/project/linux-media/patch/20211008120914.69175-1-ribalda@chromium.org/
> ?

It is. I'll review that one.

> On Thu, 24 Mar 2022 at 18:13, Hangyu Hua <hbh25y@gmail.com> wrote:
> >
> > map->name needs to be freed when uvc_ioctl_ctrl_map fails.
> >
> > Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
> > ---
> >  drivers/media/usb/uvc/uvc_v4l2.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
> > index 711556d13d03..e46a2f3b06cb 100644
> > --- a/drivers/media/usb/uvc/uvc_v4l2.c
> > +++ b/drivers/media/usb/uvc/uvc_v4l2.c
> > @@ -93,6 +93,7 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
> >
> >         kfree(map->menu_info);
> >  free_map:
> > +       kfree(map->name);
> >         kfree(map);
> >
> >         return ret;

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-24 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24  8:17 [PATCH] media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map Hangyu Hua
2022-03-24 14:09 ` Laurent Pinchart
2022-03-24 17:17 ` Ricardo Ribalda
2022-03-24 20:07   ` Laurent Pinchart

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.