Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558170pxb; Mon, 24 Jan 2022 12:11:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJxrDvtuI7yrNbn/iQdGLnIHt1J6Q/RQ2FP52+q8YTDMHgOyrSJt09OsOjFgXadiOVe0RWnJ X-Received: by 2002:a05:6a00:1342:b0:4c2:a000:bf8 with SMTP id k2-20020a056a00134200b004c2a0000bf8mr15165186pfu.41.1643055061638; Mon, 24 Jan 2022 12:11:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055061; cv=none; d=google.com; s=arc-20160816; b=N/1cv4RBUG8Qz2GyUjP8Ssd57zh/NYHiv6ANloMdaX2BWacl/G76g58R7pMeuzHObV vopC8gb7oHlq/HAAbR2gKPpvN7g4QQPLS7qYYOCOKibeI9Vi13J24ftLjUsJrEHX/SaB 82KDMCobJIjKbD8bCA+eWU8mic7TNrcnU7+/aO7c9kqeMT2nACtyFWu6W0NQ5wIpf1bZ 3OlxYFDkJUMOvHJDVnRgnFuTU9MTmX7si96YJ/tURVVvdKMSm1pFz83VhLj3MJriWpcA bWVgciApsxI2FbUPSG5GxkMHHuatJNmpreSIQRsX1bf7nbHgxpesSh9E3+fUXDj4oRoW nYkA== 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=NxmVc0kQjktoN2WL+6a0cWQcjbluGcXIrlHdTSOYGbw=; b=xOrNUmyA38IXaMYokwrleP5Fh5cgx0HNWMeCShU5+OEC9zkPrYrks+wQjCE6F/wTKB gELKG0QlK2KSJMGgCLddJdhkjqEwvH2woSwJiIzuTJP15iZrrZ77Sl5W0u7e4sjHIEcK Le9D0QzKMG8idlNtizN7im120Djdi8OxN+qUR3CKFgSAxzAIX3FPUQ6FkC468fKeB2Oc 4R6cYeDHj7BaEVnkuF/HEtcv5phWd5YCpwU/Fk9Q+7FjnFs+Ey6Yi7gVeHdAAgTKiyJo 8OaGQIWx4XxY8Nu/M6wCeZk6hEwc/SmrfuXD/G/oapZmrPmp2SodjvYq/TWu3pcGHTom jvQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dsfE9FmW; 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 e2si15207851pgi.83.2022.01.24.12.10.47; Mon, 24 Jan 2022 12:11:01 -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=dsfE9FmW; 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 S237297AbiAXTNH (ORCPT + 99 others); Mon, 24 Jan 2022 14:13:07 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59458 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345951AbiAXTEu (ORCPT ); Mon, 24 Jan 2022 14:04:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 60203B81232; Mon, 24 Jan 2022 19:04:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A845C340E7; Mon, 24 Jan 2022 19:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051088; bh=3xsSGFKg9Nzum/KgrP/Wsk5RPSyVVIwNmQfiwDbiDo4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dsfE9FmWthzZBjLcdKmzEzAO2loL/1sx6WxpmslGbg7h0564X0rgrCLk5SMn8R19L W74tkuwMDRKDScm95jGKe6bjn9fOB+q7+PtR7FczvLefjYY4Rn3P0uYysMPnKwO9ec rH8W8Tm3GhFDhgs13Y9yp0OKQRUN+T0qO/RlgmLc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhou Qingyang , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 051/186] media: saa7146: mxb: Fix a NULL pointer dereference in mxb_attach() Date: Mon, 24 Jan 2022 19:42:06 +0100 Message-Id: <20220124183938.771684024@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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: Zhou Qingyang [ Upstream commit 0407c49ebe330333478440157c640fffd986f41b ] In mxb_attach(dev, info), saa7146_vv_init() is called to allocate a new memory for dev->vv_data. saa7146_vv_release() will be called on failure of mxb_probe(dev). There is a dereference of dev->vv_data in saa7146_vv_release(), which could lead to a NULL pointer dereference on failure of saa7146_vv_init(). Fix this bug by adding a check of saa7146_vv_init(). This bug was found by a static analyzer. The analysis employs differential checking to identify inconsistent security operations (e.g., checks or kfrees) between two code paths and confirms that the inconsistent operations are not recovered in the current function or the callers, so they constitute bugs. Note that, as a bug found by static analysis, it can be a false positive or hard to trigger. Multiple researchers have cross-reviewed the bug. Builds with CONFIG_VIDEO_MXB=m show no new warnings, and our static analyzer no longer warns about this code. Fixes: 03b1930efd3c ("V4L/DVB: saa7146: fix regression of the av7110/budget-av driver") Signed-off-by: Zhou Qingyang Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/saa7146/mxb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/media/pci/saa7146/mxb.c b/drivers/media/pci/saa7146/mxb.c index 2e7bd82282caa..b2260deab94cc 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -694,10 +694,16 @@ static struct saa7146_ext_vv vv_data; static int mxb_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_data *info) { struct mxb *mxb; + int ret; DEB_EE("dev:%p\n", dev); - saa7146_vv_init(dev, &vv_data); + ret = saa7146_vv_init(dev, &vv_data); + if (ret) { + ERR("Error in saa7146_vv_init()"); + return ret; + } + if (mxb_probe(dev)) { saa7146_vv_release(dev); return -1; -- 2.34.1