Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9105935pxu; Mon, 28 Dec 2020 06:47:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzE1i/dW4NjPV9hP5ZlRtl6TTcbZs5vh7Cng42SNA/HKS0JtnpmlmPc6zXrmcf45sQN2gWy X-Received: by 2002:a50:becf:: with SMTP id e15mr43643760edk.138.1609166843989; Mon, 28 Dec 2020 06:47:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609166843; cv=none; d=google.com; s=arc-20160816; b=qSqzNTqXicavBBot/Iteg0FqUCnwYcIKcztgdEfzd52vAyPJqkEhrlyNqiK9o7P85k kQKQsmdNkiFvnzTt/eClkhvpOpSQfX9E5Ow8j78qRkA1WNeQX4BUMz3R55CKQlQ57q/1 YVwE1E3tuzty4qUQ7C8Sm21McfGe0Yis4dY/WbXTNRSxbwGTVxCAwo5GByU5EFiAuaFu /Olo4KyOnPdoKdpgFy7rdPZGiFVZnoehwHcCqCtRN3gdmPv9K+VZUVIr163DM+FR4gqb nT87qVDBGa+zPR4Ioj57ZyEa58hzUNaDda34yWzuW4Xk74uErPETA4TYw1YCFavIIf/N 72FQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gKvVPbI0ns5RQvs7EE/ilzLI9II/hufca/Sf6PM3XwY=; b=vISQVfrtDVUCBVlQQaNFEx3wKVTRj3WFzWWi9Ji2L5zkZ79oL+AAMyU0KaC/iJcN2d CPeQgZho4lKNjBCW1BjrpqJ4pe4mN3BZwcmAalt2rdigaO3El2R4ZAACfLZa4a1Undpi 4HPjnEesI5w82eSvxRfUaVELbnsPEhPxg8/liTSetgiBmXnW88DAnm+d806G9cwLrUng OdI7iUpkUrklyknVMywSaTjYnAUEdm0bXAa+KGGMOhT3QwrCMlZyRN/L1W3RcUAaqsWf K40mLQ9GWNTXu/LftZjALyMqT+eS51R3ilBRSl9qQAkIhKhHfH/HY/+ySa8YOWyD+UDR 8clg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gE1IR0X5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l11si20395711ejx.27.2020.12.28.06.47.01; Mon, 28 Dec 2020 06:47:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gE1IR0X5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503162AbgL1Oos (ORCPT + 99 others); Mon, 28 Dec 2020 09:44:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:60678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503147AbgL1OYw (ORCPT ); Mon, 28 Dec 2020 09:24:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6FA020731; Mon, 28 Dec 2020 14:24:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165477; bh=TBN0Rupb7x2AMhVcEwary34ZDTbkcSxfptAImk294So=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gE1IR0X5rIXpkC08wwDJ0eDlSw9axEwHYv5ar2k/sSaKO4vS6MGAEFrUT94cV183Q vngbBhE//EnrKTxdN6LAISXC9GmAYVucCYLClyeoV48pWCaeDvnVhZyU+eqzgjh9i9 y4r4vlIGsDRuLXMSyiRgKt8fRZAW7gBh6u/7tlF0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , Hans Verkuil , Mauro Carvalho Chehab , syzbot+44e64397bd81d5e84cba@syzkaller.appspotmail.com Subject: [PATCH 5.10 515/717] media: gspca: Fix memory leak in probe Date: Mon, 28 Dec 2020 13:48:33 +0100 Message-Id: <20201228125045.636623499@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Stern commit e469d0b09a19496e1972a20974bbf55b728151eb upstream. The gspca driver leaks memory when a probe fails. gspca_dev_probe2() calls v4l2_device_register(), which takes a reference to the underlying device node (in this case, a USB interface). But the failure pathway neglects to call v4l2_device_unregister(), the routine responsible for dropping this reference. Consequently the memory for the USB interface and its device never gets released. This patch adds the missing function call. Reported-and-tested-by: syzbot+44e64397bd81d5e84cba@syzkaller.appspotmail.com Signed-off-by: Alan Stern CC: Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/gspca/gspca.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -1575,6 +1575,7 @@ out: input_unregister_device(gspca_dev->input_dev); #endif v4l2_ctrl_handler_free(gspca_dev->vdev.ctrl_handler); + v4l2_device_unregister(&gspca_dev->v4l2_dev); kfree(gspca_dev->usb_buf); kfree(gspca_dev); return ret;