linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: syzbot <syzbot+d1e69c888f0d3866ead4@syzkaller.appspotmail.com>,
	gregkh@linuxfoundation.org, johan@kernel.org,
	linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	mathias.nyman@linux.intel.com, stern@rowland.harvard.edu,
	syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] memory leak in usb_set_configuration (2)
Date: Thu, 22 Apr 2021 14:26:42 +0200	[thread overview]
Message-ID: <94aa3e7fcbb225da66961a21c940406ada2bbd0b.camel@suse.com> (raw)
In-Reply-To: <0000000000001ad5d605c07cfd2e@google.com>

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




  parent reply	other threads:[~2021-04-22 12:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 15:12 [syzbot] memory leak in usb_set_configuration (2) syzbot
2021-04-21 18:19 ` Alan Stern
2021-04-22 12:26 ` Oliver Neukum [this message]
2021-04-22 12:45   ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=94aa3e7fcbb225da66961a21c940406ada2bbd0b.camel@suse.com \
    --to=oneukum@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=johan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@linux.intel.com \
    --cc=stern@rowland.harvard.edu \
    --cc=syzbot+d1e69c888f0d3866ead4@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).