lkml.org 
[lkml]   [2021]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [syzbot] memory leak in usb_set_configuration (2)
From
Date
Am Mittwoch, den 21.04.2021, 08:12 -0700 schrieb syzbot:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 9cdbf646 Merge tag 'io_uring-5.12-2021-04-16' of git://git..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=136ce5a6d00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=fd35e661e44323ea
> dashboard link: https://syzkaller.appspot.com/bug?extid=d1e69c888f0d3866ead4
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16ecba29d00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=143cf955d00000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+d1e69c888f0d3866ead4@syzkaller.appspotmail.com

#syz test: https://github.com/google/kasan.git 9cdbf646

From 1704504f905fe8e3eb83d63cbbbe9af60f002585 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <oneukum@suse.com>
Date: Thu, 22 Apr 2021 14:14:21 +0200
Subject: [PATCH] cpia2: unregister device on probe error

The v4l2 device must be unregistered in case probe() fails,
lest we get a leak.

Signed-off-by: Oliver Neukum <oneukum@suse.com>
---
drivers/media/usb/cpia2/cpia2_usb.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c
index 3ab80a7b4498..db3b5d6d2d9a 100644
--- a/drivers/media/usb/cpia2/cpia2_usb.c
+++ b/drivers/media/usb/cpia2/cpia2_usb.c
@@ -844,15 +844,13 @@ static int cpia2_usb_probe(struct usb_interface *intf,
ret = set_alternate(cam, USBIF_CMDONLY);
if (ret < 0) {
ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto error;
}


if((ret = cpia2_init_camera(cam)) < 0) {
ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto error;
}
LOG(" CPiA Version: %d.%02d (%d.%d)\n",
cam->params.version.firmware_revision_hi,
@@ -872,11 +870,14 @@ static int cpia2_usb_probe(struct usb_interface *intf,
ret = cpia2_register_camera(cam);
if (ret < 0) {
ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret);
- kfree(cam);
- return ret;
+ goto error;
}

return 0;
+error:
+ v4l2_device_unregister(&cam->v4l2_dev);
+ kfree(cam);
+ return ret;
}

/******************************************************************************
--
2.26.2


\
 
 \ /
  Last update: 2021-04-22 14:28    [W:0.121 / U:0.400 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site