media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map
Subsystems (2)
PATCH 1/1 media: uvc_v4l2: fix possible memory leak in uvc_ioctl_ctrl_map
map->name needs to be freed when uvc_ioctl_ctrl_map fails.
--- drivers/media/usb/uvc/uvc_v4l2.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/usb/uvc/uvc_v4l2.c +1 -0
@@ -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;
Signature · 1 line
2.25.1
Laurent Pinchart
maintainerHi Hangyu,
Thank you for the patch.
Quoted 12 lines · Hangyu Hua
map->nameneeds to be freed whenuvc_ioctl_ctrl_mapfails.Signed-off-by Hangyu Hua <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 1 + 1 file changed, 1 insertion(+)drivers/media/usb/uvc/uvc_v4l2.c +0
-0
drivers/media/usb/uvc/uvc_v4l2.c static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, · line 96
Quoted 4 lines
drivers/media/usb/uvc/uvc_v4l2.c +1
-0@@ -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 ?
Quoted 3 lines
drivers/media/usb/uvc/uvc_v4l2.c +0
-0kfree (map);return ret;
Signature · 3 lines
Regards, Laurent Pinchart
Isnt it a dupe of:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
?
Quoted 23 lines · Hangyu Hua
map->nameneeds to be freed whenuvc_ioctl_ctrl_mapfails.Signed-off-by Hangyu Hua <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 1 + 1 file changed, 1 insertion(+)drivers/media/usb/uvc/uvc_v4l2.c +1
-1@@ -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
Signature · 1 line
Ricardo Ribalda
Laurent Pinchart
maintainerQuoted 3 lines · Ricardo Ribalda
Isnt it a dupe of:
https://patchwork.linuxtv.org/project/linux-media/patch/[email protected]/
?
It is. I'll review that one.
Quoted 21 lines · Hangyu Hua
Quoted 20 lines
map->nameneeds to be freed whenuvc_ioctl_ctrl_mapfails.Signed-off-by Hangyu Hua <[email protected]>--- drivers/media/usb/uvc/uvc_v4l2.c | 1 + 1 file changed, 1 insertion(+)drivers/media/usb/uvc/uvc_v4l2.c +1
-0@@ -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;
Signature · 3 lines
Regards, Laurent Pinchart