Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9046184pxu; Mon, 28 Dec 2020 05:19:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJw360B7SX9eDwRkVfTau+OpAsyTkHu6UquZBEtNm+9JUEd7zfuVpihu9MVsNqiIQ0tuhLSS X-Received: by 2002:a50:ce13:: with SMTP id y19mr42360497edi.241.1609161565473; Mon, 28 Dec 2020 05:19:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161565; cv=none; d=google.com; s=arc-20160816; b=WRAiuR6xISoysin3pntkZiYEqAn9D3hAF5Nj9rnT++DgQt4/tit+ZEPQUTNB8z8lIo wU3Llt/rsMgGBiZjxOcVWlYLCkbgO6L/Hd8Z0tPBqD74Vqf/NT9EEyXUEgpmvWvbhyhn FE6Q+nZqHYLSldP41TEUEqs48+CdTyK3nBH4c7zfr2sDTScwAtL2tzzrJJOA7aGXrHFy z2iXGsK2eOcKRtvuYqpy6L9ZBQ2XnheZPzvq+i0Uwpr91FytqfMH3RXo/1vVan4KNdZ9 2ePT0JwT+g3NW6Vp+vLePgYMFlIdzjH/mdO7VO3OiaaAtxTCJ7efoXfywEutr08RFPKg D9kA== 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=7xdUzWCJOchMvsXyzmgYI79BP4kyIL4IVicGUNFz3v8=; b=XM0UbP5E/5/YcBiFd/GCsghpPq4lgG4A/mQ35m6cU7qYllG0DfHsF9pKV9C/6SfBLo XGJZcdp1yUk/j93oGPD3rGWunz2XfUUXfs0XdKnsMqPcxRFqd+Y5K4D5ZUtbu0LiXv+R HaDiBoLpYdy2p4l5GbiLK11GFn+mM3o1wvHhF5Je37g3+VSA14D7MjsYrsajPVKJ8d69 lPXXGvxiOyOeyBaVKKy56sx925JqBIfZ5H56nTFO3DaJOYQL6kDFaFZGd493ItS3zYj+ cAJYLL0Sf8G1oB4l2GWw7FFPSmkP8pVrUaejYklvLF1kemS2Q8EM/pzs6j5klzBDyl+i Coag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cXQ6EfSs; 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 dm18si19626354edb.422.2020.12.28.05.19.03; Mon, 28 Dec 2020 05:19:25 -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=cXQ6EfSs; 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 S2387419AbgL1NRF (ORCPT + 99 others); Mon, 28 Dec 2020 08:17:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:44654 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733148AbgL1NQR (ORCPT ); Mon, 28 Dec 2020 08:16:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58B41207F7; Mon, 28 Dec 2020 13:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161337; bh=Zk/fkRtIIpQdewPWSBL5BjP2GLGAsjF6KeSuKgOzpdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cXQ6EfSsz7sjKYqZruJt8Jyzz+uIZx1f0jgSW3qMcNPlQewAhcgpCJI++kyV3phGX +6bL5D6RY47Gx7VsXj1GrMX0C/E3lTeDo6Nl5OKyoC+H0QPvdxR5rWUM/x2kdkyb2B K+w+1QXUKmJ3Tqa/075FU+5TmFN/khn1PKffF07c= 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.14 181/242] media: gspca: Fix memory leak in probe Date: Mon, 28 Dec 2020 13:49:46 +0100 Message-Id: <20201228124913.593561819@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 @@ -2140,6 +2140,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;