Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3588732pxb; Mon, 24 Jan 2022 12:57:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyd7WSQquZjfUHdPHfdcF14oOYEkuQTNXjlkbf6VRoe1KbGKIJXMBV6Fc8LRJ5lWEsNYsqA X-Received: by 2002:a62:7711:0:b0:4c8:dc56:7155 with SMTP id s17-20020a627711000000b004c8dc567155mr7644125pfc.23.1643057840282; Mon, 24 Jan 2022 12:57:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643057840; cv=none; d=google.com; s=arc-20160816; b=KG0TWUMXzplqpfp0b9uCGcuUMfB+ehe3cgkPDYfURGVU0kw/0lKNILLH5y0T/uf3wN ovRFBFGwOr+ktEAnwV4UtbuwM5ASWuP/kc5pWm/yldOxKnS7YbKMC4Hc1BqqwshqkwhW SY79jj6+5BZBu9n7rV36aipEeonPrd0/8XLurT1aXvFODel8T9Bm7chV4up98gRaOYgg eagzfLBhpL3oQKI+oOKKifJoMBuifaj5NvlOJP5Digo8AOSi/XNiClQLuLtjvITd+Kr5 GdcM6ngmn7PrqfjSjv3cGiuCdFFTo7W9Q0Qs8jofAqkKrZOGW8geM/0d7U8PnY8PLG0i wyPQ== 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=Vpg0VzMoy5v0s1jfuLT9Hga9YKGJt3/8nAy//oWxulg=; b=KnQRa91M7f0ML/NwvTo2R3wb7PH0Ho/o5AwoyVlgJKWnwG2uiogt5+eL6zcwjrHJtW djfglZvZYDxzP+q4/ZFtrBkjavPrl4/GZ3s69LKitnIqck+L86ihMOaA0wBgH7EkJ3ND 9spkygUAJT3wvRoDoNOMF9Uq3vKan0PbdodbrrZvn0o8gVXUdzgtup6B3btYYhlFFQ9Z qZWJSwOByxrCBp25hqFJ48IJDmDlRp6WCe6u4OSXsTFn6fAH/Z3PPTTthgRuK5cZF9n8 zAcizbQT0AunxHAyB5RkRNig2ERfJj6pBIT8Zu4U4Ifx+8dAXfsuJpJ+lEogu80UmEr/ 1egA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qvsgcyVH; 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 j6si8160286pld.55.2022.01.24.12.57.07; Mon, 24 Jan 2022 12:57:20 -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=qvsgcyVH; 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 S1380706AbiAXUQr (ORCPT + 99 others); Mon, 24 Jan 2022 15:16:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347532AbiAXT6p (ORCPT ); Mon, 24 Jan 2022 14:58:45 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D49AC047CFF; Mon, 24 Jan 2022 11:28:00 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id BAC7460917; Mon, 24 Jan 2022 19:27:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94CE0C340E5; Mon, 24 Jan 2022 19:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052479; bh=tmTLQNf5BhZCWTqkO9rUODhM5eaul2RlC0GLt8NNmhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qvsgcyVHEpSnCTW9ddLpVAkoW+jCybLMC++JaRnGtxw3axb4zb8QvDPZ+AStk8X6s bPQVErX5Idsl5zpvuGt96huWVh+jppYfmNP4baf1lnpxiWqoSGGtj5dbIXooOzgK6q 6gDkB+r2ctMh3of2EVBM0UgHqaXp8fjo3sjCpcIw= 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 5.4 073/320] media: saa7146: mxb: Fix a NULL pointer dereference in mxb_attach() Date: Mon, 24 Jan 2022 19:40:57 +0100 Message-Id: <20220124183956.213783043@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 952ea250feda0..58fe4c1619eeb 100644 --- a/drivers/media/pci/saa7146/mxb.c +++ b/drivers/media/pci/saa7146/mxb.c @@ -683,10 +683,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