linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: uvcvideo: fix possible memory leak issue
@ 2021-12-08 17:41 Ameer Hamza
  2021-12-09  8:54 ` Ricardo Ribalda
  0 siblings, 1 reply; 2+ messages in thread
From: Ameer Hamza @ 2021-12-08 17:41 UTC (permalink / raw)
  To: laurent.pinchart, mchehab; +Cc: linux-media, linux-kernel, Ameer Hamza

In uvc_ioctl_ctrl_map() implementation, there is a possibility of memory
leak if control id name is not listed and kmemdup() is failed somehow.
This is a rare scenario but possible.

Addresses-Coverity: 1494069 (Resource leak)
Signed-off-by: Ameer Hamza <amhamza.mgc@gmail.com>
---
 drivers/media/usb/uvc/uvc_v4l2.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index f4e4aff8ddf7..711556d13d03 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -44,8 +44,10 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
 	if (v4l2_ctrl_get_name(map->id) == NULL) {
 		map->name = kmemdup(xmap->name, sizeof(xmap->name),
 				    GFP_KERNEL);
-		if (!map->name)
-			return -ENOMEM;
+		if (!map->name) {
+			ret = -ENOMEM;
+			goto free_map;
+		}
 	}
 	memcpy(map->entity, xmap->entity, sizeof(map->entity));
 	map->selector = xmap->selector;
-- 
2.25.1


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

end of thread, other threads:[~2021-12-09  8:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08 17:41 [PATCH] media: uvcvideo: fix possible memory leak issue Ameer Hamza
2021-12-09  8:54 ` Ricardo Ribalda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).