diff options
author | Colin Ian King <colin.king@canonical.com> | 2021-09-17 13:49:30 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2021-12-07 11:29:53 +0100 |
commit | 4b065060555b14c7a9b86c013a1c9bee8e8b6fbd (patch) | |
tree | 67ac7fc53564a6b684d8fab6c6a0dca909325440 /drivers/media/usb | |
parent | 4383cfa18c5bbc5b9b6a9e77adc12aec1c20b72d (diff) | |
download | linux-stable-4b065060555b14c7a9b86c013a1c9bee8e8b6fbd.tar.gz linux-stable-4b065060555b14c7a9b86c013a1c9bee8e8b6fbd.tar.bz2 linux-stable-4b065060555b14c7a9b86c013a1c9bee8e8b6fbd.zip |
media: uvcvideo: Fix memory leak of object map on error exit path
Currently when the allocation of map->name fails the error exit path
does not kfree the previously allocated object map. Fix this by
setting ret to -ENOMEM and taking the free_map exit error path to
ensure map is kfree'd.
Addresses-Coverity: ("Resource leak")
Fixes: 70fa906d6fce ("media: uvcvideo: Use control names from framework")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/usb')
-rw-r--r-- | drivers/media/usb/uvc/uvc_v4l2.c | 6 |
1 files 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; |