Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9275863pxu; Mon, 28 Dec 2020 11:07:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmlxZChzMe8kuiqiC3zLdIcGaS11dCWLyUn7tETZQYV3uWLeLYpPdAxl60TCZ/M8zq3R1Q X-Received: by 2002:a50:9f4a:: with SMTP id b68mr42951190edf.296.1609182462356; Mon, 28 Dec 2020 11:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609182462; cv=none; d=google.com; s=arc-20160816; b=qae2CWlO6RGs2D5NE4LYVuTCEXBfiyVJCR4NtecCWgQqijqifPlajbIpcWfWfrjmDc TWPCBIcfzuKKBl1A6DQ1VvX87wmNLCfh/95BcVKVT0oRsZr1ywdPX09a5PGW2yshosog VynskZh4YDiP0cmUFojdNnfur39nEOOKisD5VLiRXv2RQ7TrkrIjSecVQmalsVqcocNf Xvo2OXwxWaI+nsZzMr8AZmJK3nSwvocWQ7NeZ3lm6a3zc8JyRiiQaFUAqu2N+WAvf5cR dSRL7I3lDeG+6kSEOwW/a7RWdbjcuCoZUUOc5BliQ3GD3eeV9vNVz2Emy3wcI8Y8FRXT 8Thg== 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=ghy0KvzHd5SdYY+9btIM67GICXcPNwbc+JLv8YxjdzhSba3RlDQHq3TndVZfBe1rNx ogBUrf95kBZ9dpqzn3HqqtCjV5Hnu7lZv1IbbGMwnsqOsfiOZX7IEg5REcM7wyJrMOt/ TRFH48AzkJwd7tN9eBeiiNZAmtiCE53xDDZNdWBtpkehYCEWCiYQyQTHANxJV1rxVHrU VM/iXYb8AcT28LmqSpM94LtyF9NIO3X905UwcmOOS33VfdzRPTQMPZhIiBD6Q2OI0I6s llJogRhJYi5EI8K+LaRLRGF/8uj+Bk8/GRwwV9WXYoLwsc0UOtVCjoya6N5TS1O6GAeU wLIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oDaVdzx0; 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 hr9si18260793ejc.729.2020.12.28.11.07.20; Mon, 28 Dec 2020 11:07:42 -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=oDaVdzx0; 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 S2391532AbgL1Nws (ORCPT + 99 others); Mon, 28 Dec 2020 08:52:48 -0500 Received: from mail.kernel.org ([198.145.29.99]:54154 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407124AbgL1Nwd (ORCPT ); Mon, 28 Dec 2020 08:52:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1606621D94; Mon, 28 Dec 2020 13:52:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609163537; bh=TBN0Rupb7x2AMhVcEwary34ZDTbkcSxfptAImk294So=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oDaVdzx0nSA+tNALvu1bLAgEj+iuwH+hst7zHh1FZiDZ0CDIn/iMlIzf/MLa9/P30 0j+prbSGp0mrfYl5ll57EOG42gRq2gss6rir+FxbF1CYjNVXNnYKsrBznZlcjM1CD+ tdrNubHA2IIk8caalPUo2nUt3/Js1BgT+eJUGVnI= 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.4 321/453] media: gspca: Fix memory leak in probe Date: Mon, 28 Dec 2020 13:49:17 +0100 Message-Id: <20201228124952.653068350@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@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;