Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3555323pxb; Mon, 24 Jan 2022 12:07:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4rEUeTItvoS8WDk7suiSl4m1wjslEia4cGc+SvqPfnw+stI+0owp3Y6l6D873IkBXoBmP X-Received: by 2002:a63:9142:: with SMTP id l63mr12980897pge.476.1643054838218; Mon, 24 Jan 2022 12:07:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054838; cv=none; d=google.com; s=arc-20160816; b=QxXBdcG2GDEdgc80nP4GjUx+PawYMNfKeDTrfEJPw3k/QGDMLul9Jmcwzw76UnlQ+/ v2DB4KOYXMPTHGKrRlbXL74tzzAEgtXtINVLnpb1g1ppt8swT3IjVfss/a041NoVegnx FknjwYSpmIxw9r8H75Cw2y8vWRfLwcjqj0GJBCO3hmUeArlgdIZN0mCVBPh4zjxNwWsN QhfMXvrZfE2H8liabFl8erPpHUI83TG++88xYC2QvvAy0zh0CJc1s5dr4MRDItFTl5lk yO8ORd2WLccE1aEenOaDI9azJ0Hm+vk7XfBJ+1QE2VhpDhUfd1HbVoeQMIbkTKAhq/D0 Rz3A== 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=jxiaMBH6+H/WBhKERR257TuJa6jO/0IYUACRqGoXB2e0zDlw1QqeUr2jCrVo6rCMpT 9/jLQVCel+I/titXunwZx5/MHPtTyMNYFdE6TAnM1uMvbvu5huVMM2PjhPKyjfyibbo2 r6uNBLMxGvKH7NQLXz+bWbsGDaEBS1tuerDD8mn4Ir6YbH7/OhJHICJYnOEdEZh5l3OF hSWmH5HfkYNrvW0T/zkyO0K8t5Y+78Ato8odxDxQKz3k3s+kOwfhw4JFCwgQLQ+/SEb7 8VDsAPPDXP0vd2TlmRkfC/Uxjq3l5Ah9C3B05Za6vg4y8EW81l/ERZM6ilBqb3KXnqq/ EQ8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lQaNuxM4; 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 b19si14093578plz.574.2022.01.24.12.07.06; Mon, 24 Jan 2022 12:07:18 -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=lQaNuxM4; 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 S1346383AbiAXTF0 (ORCPT + 99 others); Mon, 24 Jan 2022 14:05:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345496AbiAXTAV (ORCPT ); Mon, 24 Jan 2022 14:00:21 -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 D144CC0617A9; Mon, 24 Jan 2022 10:57:58 -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 8EA58B81227; Mon, 24 Jan 2022 18:57:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94CB4C340E5; Mon, 24 Jan 2022 18:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050676; bh=5NY77zdV9ozn/+VEAlvfkSk/XENHtvV6igQMct3x6Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQaNuxM4oZGQh1j2icAQG+PnRTpPwRSjjuwuKgWTfkjVBCPB/laO4qcs7TPVcGN+d bIerxKSBhgAZZx7QrVe/+ngPfRNL/n9tRudn+1JaDNKmm56mrC9UG+kp8wtPHaRzwh ww5+ZD+G/Cw+N7NqcMXT2ZYflszIg3TU8UvbXvcw= 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.9 045/157] media: msi001: fix possible null-ptr-deref in msi001_probe() Date: Mon, 24 Jan 2022 19:42:15 +0100 Message-Id: <20220124183934.223028602@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183932.787526760@linuxfoundation.org> References: <20220124183932.787526760@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