Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3701939pxb; Mon, 24 Jan 2022 15:47:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJwq5RH1bn/CJlnPhv7d1HjBpTpraLOaUpltCusiRdl71eY4spD1h2TL3Bm+eOTW4oa8cpRD X-Received: by 2002:a17:902:ed84:b0:14b:59b9:cde5 with SMTP id e4-20020a170902ed8400b0014b59b9cde5mr5210241plj.125.1643067965660; Mon, 24 Jan 2022 15:46:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643067965; cv=none; d=google.com; s=arc-20160816; b=VrYbgw2WBLemAiGN9fh8EqT4K2l62JH5z5wBZRk6i2bbXpUYxq2jYb0qOdXHw8aaHp fVnv4ncrSdHvrEw/xvAVOEsxzj6YXSIANLOPTKBZVHCUHguleHB7x4OaFq65uAuCMvGx i9HjHB+ry7HyVrupwH+tyqS3RkkptNgfuuOk7+ccaL1cpGMWnqqLgu7P997ZryXtxCQg sSIE1R1TuPYFFcnFvqRafK6LwxZ7F5MW2R97jVzbRS+a1+inh0YkbRTJwZ4hWxV2+bl5 kStGHQ5UbtoHZRrX4SK/vrkj1YDTRXY1BSxO7zt01+VEgZYxxgoXezbaGnj/eJubtzMS tR/Q== 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=Zysvv1LthjSAF6028L8FbldXeBbFHDjLXk9sCOTpqcw=; b=n141wsA8uJJwEBU+/bR8S2g28L4mfwQpS+Abkc85OqckeR2JmhP+2K1bmKp0lAvfCU hM5StpHfGU7PCMlI5Rop6FL80orHAyNRnaTZcD+YQPFbGVyoPtH8BTuEU93pPEfopHFk U/YEEt2lqxFvWDVU825vXo0Ya1G4I7HNhrxwTtSup1z3oT3dY86YaSqhxiu9XZaFsimv t41q7XC2tbKvjXzq5AJE6+ysGfgHcsAAbiA2SFTP4/K9PSxGDszhgAnheaDyn0AUMVZA xMKDTvaqm2ZdrMKOSf7iQRAvEGBkCqk9VfyOawpAV3d6yCxfA8p+ynwflWx0N9WlDcpq 3r9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PSGcYUwi; 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 u8si5608695plg.402.2022.01.24.15.45.52; Mon, 24 Jan 2022 15:46:05 -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=PSGcYUwi; 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 S2360232AbiAXXgR (ORCPT + 99 others); Mon, 24 Jan 2022 18:36:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1838710AbiAXWry (ORCPT ); Mon, 24 Jan 2022 17:47:54 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20B3EC06B5BB; Mon, 24 Jan 2022 13:07:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id D1A6BB81057; Mon, 24 Jan 2022 21:07:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F3326C340E5; Mon, 24 Jan 2022 21:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058429; bh=dqbWfEMlNE/Ni041E7Yb6Yct9cWyfdGrWOafYB2jzak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSGcYUwikDNEfFyDCD5JUiORZtillwmuZt4I8nFf2kbI2NciuHjyDRtvSro5bkuy7 2tt8r/i1eHec9aMj1q4amFy3y3E4O6CLQbpokYwU9PKYr39zgbCRiClJAkw0KHMb1Z 2n1ui2o7/MB5p4VF6OmYX6xuvnhh734yDpbriLGM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wang Hai , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.16 0286/1039] media: msi001: fix possible null-ptr-deref in msi001_probe() Date: Mon, 24 Jan 2022 19:34:35 +0100 Message-Id: <20220124184134.899133471@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Wang Hai [ Upstream commit 3d5831a40d3464eea158180eb12cbd81c5edfb6a ] I got a null-ptr-deref report: BUG: kernel NULL pointer dereference, address: 0000000000000060 ... RIP: 0010:v4l2_ctrl_auto_cluster+0x57/0x270 ... Call Trace: msi001_probe+0x13b/0x24b [msi001] spi_probe+0xeb/0x130 ... do_syscall_64+0x35/0xb0 In msi001_probe(), if the creation of control for bandwidth_auto fails, there will be a null-ptr-deref issue when it is used in v4l2_ctrl_auto_cluster(). Check dev->hdl.error before v4l2_ctrl_auto_cluster() to fix this bug. Link: https://lore.kernel.org/linux-media/20211026112348.2878040-1-wanghai38@huawei.com Fixes: 93203dd6c7c4 ("[media] msi001: Mirics MSi001 silicon tuner driver") Reported-by: Hulk Robot Signed-off-by: Wang Hai Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/tuners/msi001.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/media/tuners/msi001.c b/drivers/media/tuners/msi001.c index 78e6fd600d8ef..44247049a3190 100644 --- a/drivers/media/tuners/msi001.c +++ b/drivers/media/tuners/msi001.c @@ -442,6 +442,13 @@ static int msi001_probe(struct spi_device *spi) V4L2_CID_RF_TUNER_BANDWIDTH_AUTO, 0, 1, 1, 1); dev->bandwidth = v4l2_ctrl_new_std(&dev->hdl, &msi001_ctrl_ops, V4L2_CID_RF_TUNER_BANDWIDTH, 200000, 8000000, 1, 200000); + if (dev->hdl.error) { + ret = dev->hdl.error; + dev_err(&spi->dev, "Could not initialize controls\n"); + /* control init failed, free handler */ + goto err_ctrl_handler_free; + } + v4l2_ctrl_auto_cluster(2, &dev->bandwidth_auto, 0, false); dev->lna_gain = v4l2_ctrl_new_std(&dev->hdl, &msi001_ctrl_ops, V4L2_CID_RF_TUNER_LNA_GAIN, 0, 1, 1, 1); -- 2.34.1