Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558217pxb; Mon, 24 Jan 2022 12:11:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyajCem8BHqwuK4POSyc/F56aZ8sC+ONjNxjfO0/oeY35/4tZBQ25kK7carkZl5PFFl2AWv X-Received: by 2002:a17:902:868d:b0:14a:d70d:a29a with SMTP id g13-20020a170902868d00b0014ad70da29amr15942190plo.5.1643055066376; Mon, 24 Jan 2022 12:11:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055066; cv=none; d=google.com; s=arc-20160816; b=HsF7E+rgPhi5ExFxtQAdsfewpTz79gRLMiu1Ixh070A7vNRXTAJPxD+XUqAYjRl+O8 tQVzPd7pKEPcuVsRH4abqerQuLnK2UR2xW+bCecSkqYgEkuYf8FogzTjDEW9sWVYNqNj iKUX74WqL5cekQGOGBOsgJPbBStPGeWXKsI20iIKgZlcISKqM+FynCPBsVV7jf8JpX8Y g6OkYw7T9pc3vUsJ+kXzHlOPCaABtgMLd/PJtmfyYBzn+f7omHG20RYgITqSpPI5HWsk FLhx2pWEPtA82paTsQA/3ziEE7FmkouJsCw89koS/qlEv4qpmLLdQ88BznKo8cMIyl3v w89g== 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=LzZ3rYjd5mwbV7hQXrOVu9xQXCAToOaHRTDfw+SEnHM=; b=ux6Il6D1w0nHdo/FaGNJTl0//0do7FsoM7BcUR+dk4mrWo4NrlV7/GqxLQnSCJYUZN emI5srmJT9IxlfQEHLILuYWD42L6GJq9EwKlk2puatI0vylcBOYLlUDL6N0RglyFSnLK KKhooxMJq//4IVeIB5O3N1k8wJiYKcxsCTRMRmdHjmUFIjlA2XrL0iItLKwxIbuPJnIR iYkyltxCc+Lbuqwzxezt9QsCFDIX5akjSv79luBtrrCZr7vxV/fDLB5jw5sc5CpIJM2c CV0prbh3fK/G/0BnoEsvczfbVvLzY3C5G+YqU3HL4mk1YGlfGIKBwT+f8/3/GdqAbNPP 9pNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oC9s83ED; 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 p20si13580144plq.541.2022.01.24.12.10.53; Mon, 24 Jan 2022 12:11:06 -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=oC9s83ED; 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 S1345847AbiAXTNV (ORCPT + 99 others); Mon, 24 Jan 2022 14:13:21 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:35190 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346121AbiAXTFE (ORCPT ); Mon, 24 Jan 2022 14:05:04 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 777CF611F9; Mon, 24 Jan 2022 19:05:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58EBCC340E5; Mon, 24 Jan 2022 19:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051103; bh=5NY77zdV9ozn/+VEAlvfkSk/XENHtvV6igQMct3x6Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oC9s83EDntQZRbUXWRJqDT21vfPTXyVHrlKhp0RLa8J6KgdHy+XdouZwTGeGzd8Dr wUhrWFKK8UwNJjvgY4X5wL5eJeZO27H59qzVGxxPqtGx//VvGVxdD7edAcojlG2m1z D0w/WypYfJqqg1dcDi+4ADt88BUwOGHGj/MSOUDo= 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 4.14 055/186] media: msi001: fix possible null-ptr-deref in msi001_probe() Date: Mon, 24 Jan 2022 19:42:10 +0100 Message-Id: <20220124183938.898353459@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: 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 3a12ef35682b5..64d98517f470f 100644 --- a/drivers/media/tuners/msi001.c +++ b/drivers/media/tuners/msi001.c @@ -464,6 +464,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