Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3547222pxb; Mon, 24 Jan 2022 11:56:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFxubVQjKxmK2LySAWugyplspAKglaL4Yn8AdKr0BHQz3GTjZj2rjR9sM0KsRdvU1ELs84 X-Received: by 2002:a63:d50f:: with SMTP id c15mr1366304pgg.521.1643054213355; Mon, 24 Jan 2022 11:56:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643054213; cv=none; d=google.com; s=arc-20160816; b=W5wnlmwz1Xk3YFbO57Bn4FfTrGrTUC1aba+//ixgFqVOv/85wSrPZnZ7n3cudPSUg3 oBpmg8HzzN+0gfX7o+Zq6vWsdMw8STGiUQqUmytr5eefZRENONanK4HT6CnMxbnaOD6Q jg1BXuVEiSGKeujBAHXg3zPR66osrKpPl+K+taCnA3jKQRoJUrAKvxIqd+aG6EzsNPm+ e/zc6PwtFWj0KnddvY9eoVMRqRotG71z4AapVFysD8hMfcnPijBP1fwzhWSR+ycLudg0 xqoI+KpslOOQW1Yfe9omtoDxiCVlviXJUuspkIF3bY0SwL+mVUr9mbu4A5bHRaRiJ/Eb aHPQ== 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=YsoseKPqhvqAflTpHXAx/AvMKzO6XGILUxUM0YfR73BpkV1oO254VG8l3gzEPmrHfJ xn6iXtINW145DkeaYRAKsIeVChPlY+ekjABLXphum5j7h0GCePnRZeqHPiOzVWwDJidj LsAn/OY9Am+jPUTUXZ6McDf/8G1q+7M2ek/mOGFkoNhnFTzoYkOsR69Pb1HPkX9QO1ss oJ/6vdvT1sCkbQthWvRXSdG/f+wF/NEF/ytlR5ElOsYfcEJwLXr9i0bJO5Hm1pn16/h5 2oHgfSmeFPc3YK+An13oDFdAvB31/6btYQC0m5eaXO8TQZRIrANG2GCjCrV84MuodPpY I+ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Ah/ACyyZ"; 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 n22si13966331pfu.185.2022.01.24.11.56.40; Mon, 24 Jan 2022 11:56:53 -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="Ah/ACyyZ"; 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 S1343552AbiAXSu5 (ORCPT + 99 others); Mon, 24 Jan 2022 13:50:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245516AbiAXSth (ORCPT ); Mon, 24 Jan 2022 13:49:37 -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 8A4ECC061768; Mon, 24 Jan 2022 10:49:31 -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 28460614D8; Mon, 24 Jan 2022 18:49:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D69A8C340E5; Mon, 24 Jan 2022 18:49:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643050170; bh=5NY77zdV9ozn/+VEAlvfkSk/XENHtvV6igQMct3x6Ls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ah/ACyyZvfRyePn6l6DX0Y2wQI19zWNaz7yc5r7mh/Q32QnarlmufGmvUfLrYn3+1 S65y3gcQGfd0dtKEEM4/xjFPemksMCgBjPJgPEDufc4V/uDKB4nPh4xC5Jwcg5ZMCo FbGtq5DQaS+TN8oX0amTQFF/EtwDP7N0ByvDlZoQ= 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.4 032/114] media: msi001: fix possible null-ptr-deref in msi001_probe() Date: Mon, 24 Jan 2022 19:42:07 +0100 Message-Id: <20220124183928.111280323@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183927.095545464@linuxfoundation.org> References: <20220124183927.095545464@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