Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9180920pxu; Mon, 28 Dec 2020 08:35:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOPNn/uTUY9s3MQukIzpW827YwF3IEnMBstwj5yY0A89KkoM4iQHPQu/INx7oMTrcB2v0s X-Received: by 2002:a05:6402:1d3b:: with SMTP id dh27mr43584478edb.238.1609173327565; Mon, 28 Dec 2020 08:35:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173327; cv=none; d=google.com; s=arc-20160816; b=MiylLTMO85A7LjqJevmphv01i6GqS4KXVDzzdAArmuDnDjmqDYnnk/1Ic89iIzzng8 yvUe6PaftFsNzDqf+9aNJaH5rxPO1KRZjBM9t7j3pkoSCwOE2SykCOOI2JXmiTgfNWWX pFOaxJRT+KmzL5tU2CxQhY04cDYurgbAgkr5pCdSVpBKjFoSn2m/aYWAd9dh9buwrFng N9Utbeo8IrzhWt/5IdQPaRCxJWK1yNqLCJJ7JJkyT5WFvtDi9RtATahlDymMkW5Kuozl idkRY7Ryyf2NK9qMpPMGL/79QS0mDROu5zC2tS+1cLIWbsI4ATDRfpfDY8zq0e2Jlbz2 WIiA== 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=IFffW/GCRgzVO2Leo2yWuQkFLcPthOETP24lNikx6sM=; b=vyR/qvySGaD6+ctep2SJMF3qQY9dju6PO7yaPJe7sNmaaAfkLvlTCBuHbmRMhxeO1D SjGCuqh0LqYeHGQErooIKgftosYufMWjyjeZ/hmgj/ML0jC/xC/bW6dun0qrxn1Ulm8T G5AGb5cGSXu280AwNuOfFa1FWpd9406g67HGNm+uEnmRcGVYwxj+4ET1fHXj3LuTI69Z o4DYx9MVecqXcpOH+sLxhhGmQqP+c50xB2K0a9rfTpSXTAjA4Zlz6pBGor0tMy91xDTJ h41mPaB1RvvH+Cw92F0FRgpx6EFoIMYresWu45HLRNuBuVC839fZvCBP3nOaABQg1awT lO5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vrhGJp0K; 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 dc22si20306398ejb.568.2020.12.28.08.35.05; Mon, 28 Dec 2020 08:35:27 -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=vrhGJp0K; 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 S2634085AbgL1QdK (ORCPT + 99 others); Mon, 28 Dec 2020 11:33:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:33042 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730567AbgL1NFL (ORCPT ); Mon, 28 Dec 2020 08:05:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EDC1D2242A; Mon, 28 Dec 2020 13:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160670; bh=RYbOWRvejdBBbgW8PpZCjSO4sdcrLbiiTMSCXbVxNYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vrhGJp0KTBW8M/YldoR/pgfEkT0KcFupA2GcqfqSpnk/m7xY71GDT2n2qBmAhbRQ1 9nQQopgYe3f4hm9RaXOBiQ63cfsXqZJ72o44Soz0jrCIjf8iMjh7Yhc8IXaz8UjcC4 OB9zOPWr36PMZ9OGn0YKyLD0N+gNXkHtl41wLUBk= 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 4.9 131/175] media: gspca: Fix memory leak in probe Date: Mon, 28 Dec 2020 13:49:44 +0100 Message-Id: <20201228124859.594845849@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 @@ -2145,6 +2145,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;