Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2134106lqb; Mon, 27 May 2024 08:55:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhhV7HDOUcb6sFACjBM/ySkUvzVNCyVHPq95TMr2UxI0o5D2TalxroG7eVdIHavDYBKl3u3M+LQ1IRN0W4QkwGwYRKiadhABORky3ccA== X-Google-Smtp-Source: AGHT+IFmzImoZFNlX7fAu1yOPVJAKEKS869NMSVLAJsbwQYwQuK9pPJCB2t5FoaGBgDv8WSi6URH X-Received: by 2002:a05:622a:16:b0:43e:e6e:21dc with SMTP id d75a77b69052e-43fb0dc00e1mr105266801cf.12.1716825324423; Mon, 27 May 2024 08:55:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716825324; cv=pass; d=google.com; s=arc-20160816; b=AxloSem+rxDY3c+jj+0zUDaMrDdOJACE5YGBqqEZK6dwRMsncAhomuM3U/CHPNkNhP Ac1UyLTpCEdpmFPgE41d7UrGVPFADDvm5EXsAA9DibGg20P4PCUx3yhJi1QCAr1N7nTt qW1FsIMRZA9lsrA0T+FKB/xXGgFe0Lrx6eUw2/TfSW/ZCksCJC10u1ZusU9zd48a33hf pd6X0yCB9soV0hqXCtVVyrSJZvqlw3eHn5cptzRtyhX184t215o0P3ROEwhVGRZqgMbG JulFRYWd53Gr16XRWV4FHEXLkbgWZNDjMXrZd/Bhm5vJwOvUmvvHQiyBQS8r5u714X+S xDVA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bsBcLy9B1hjvlUuPNfRHweMfQF+FuejzaH2XPhOp0Is=; fh=WJVf4yLtKrymvGdsTfLZwrSQ7rDQ3TjQVgGQqxnR/rs=; b=EmF4Vs0rjskr6o2FKmi4KTglTZrbhTFMo9g480XFbPcssPXW7Mg8rIwql9/06Kxqo+ mgptmJMri36WnZ0JDVGhIMn7lteLHPAw2RpwG/54VXPSi4jNBQbrAwbEkLg9E22kcvwf jSeVzwslQ6tc/Xqpqz+ZqgdzRU23sv8gA5nuSGMpBsrCtCAy5tN/x3BPKWwI3gtxFniP rPjQfNxhAGrfrxjcwDwfuSXS8hFb+LA+rzTsLH9o0PC/FfTFe/swiaeCc5KfQmo0lgIT Y6Zc6VHvC5VxVqvREWYhMjBRpuWv5Nj0kkmOpQtTs3Y4efwUuBruuXoNg/jOJA8PCjsz k7Xw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JmsMdfB9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191116-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43fb18ee00asi89460011cf.799.2024.05.27.08.55.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 08:55:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191116-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JmsMdfB9; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191116-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191116-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2A38E1C21202 for ; Mon, 27 May 2024 15:55:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 54BFD155C9A; Mon, 27 May 2024 15:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JmsMdfB9" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 76D4479E1; Mon, 27 May 2024 15:52:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825152; cv=none; b=QGSqEH8J036+ypgHIsyobVgWmaQaJ12Lc4dtzCDzBqRUTOL8Hy4z/rM3VNYWpEQkobYu9MDsSMDS/QFvIlBFdJjpmRyrKGqxYluiWHgclTBgiNi5Bp0u6tfaAEIibSEPkmhV3qdpfQlk3EgVL2ogoSZb5ehKtDFUedEwEHe9ArM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825152; c=relaxed/simple; bh=Tw3zDUMJPnwZjnIYo1ORXpO1GQ+JnxUHJ0CmsdPjWLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GiDM4usyluj3SLbxW+20oQqRNQpwkJH/reo56vxTBoze54sowJ3K5BguxTy2jukIhdkRt1ENWD0I46n1b1ES8amSERALPaR5wNLdgwnDw5u86RW2/k4M821IYV4xRuXtwuNVEtqRq/lTuR4nADDoOqCRRDXYJXbeyOYhzugoReA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JmsMdfB9; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BAA8C2BBFC; Mon, 27 May 2024 15:52:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716825152; bh=Tw3zDUMJPnwZjnIYo1ORXpO1GQ+JnxUHJ0CmsdPjWLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JmsMdfB9mLtMyTWbv0BnanBHpOBgCIrjdCpV+Ou8cCa/pQpMkQ6Tzbm3Xl0p97Zlu rk7yLxEYIip4XdfyaLkAGZqY/7cnwe2XF5VeSVt5WgoK/nGFMjPeNPVCiU9QM9FzZp no0dt5YMVkG/NwBMI66TzW9iFqTm+jWWh9mBb42d8VfP80XhzM+7RRDgvAM459zbLQ qZUvXYbrX3ZECSRMS1QEkpxNkV+mKhfbD1ok8H6uGXLLJVGH/WSBOL2lAD3zDsAUTq uv0EF7csEhZfCTVFWFUiYyOR7pPARs7WZOAbStXIxDpvdhh7tifW3aMkkCOZirDosj MzNQnZMZc4ilQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zheyu Ma , Mauro Carvalho Chehab , Sasha Levin , hverkuil-cisco@xs4all.nl, rdunlap@infradead.org, gregkh@linuxfoundation.org, mcgrof@kernel.org, andriy.shevchenko@linux.intel.com, hkallweit1@gmail.com, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 6.9 17/23] media: lgdt3306a: Add a check against null-pointer-def Date: Mon, 27 May 2024 11:50:18 -0400 Message-ID: <20240527155123.3863983-17-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527155123.3863983-1-sashal@kernel.org> References: <20240527155123.3863983-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.9.2 Content-Transfer-Encoding: 8bit From: Zheyu Ma [ Upstream commit c1115ddbda9c930fba0fdd062e7a8873ebaf898d ] The driver should check whether the client provides the platform_data. The following log reveals it: [ 29.610324] BUG: KASAN: null-ptr-deref in kmemdup+0x30/0x40 [ 29.610730] Read of size 40 at addr 0000000000000000 by task bash/414 [ 29.612820] Call Trace: [ 29.613030] [ 29.613201] dump_stack_lvl+0x56/0x6f [ 29.613496] ? kmemdup+0x30/0x40 [ 29.613754] print_report.cold+0x494/0x6b7 [ 29.614082] ? kmemdup+0x30/0x40 [ 29.614340] kasan_report+0x8a/0x190 [ 29.614628] ? kmemdup+0x30/0x40 [ 29.614888] kasan_check_range+0x14d/0x1d0 [ 29.615213] memcpy+0x20/0x60 [ 29.615454] kmemdup+0x30/0x40 [ 29.615700] lgdt3306a_probe+0x52/0x310 [ 29.616339] i2c_device_probe+0x951/0xa90 Link: https://lore.kernel.org/linux-media/20220405095018.3993578-1-zheyuma97@gmail.com Signed-off-by: Zheyu Ma Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-frontends/lgdt3306a.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/dvb-frontends/lgdt3306a.c b/drivers/media/dvb-frontends/lgdt3306a.c index 2638875924153..231b45632ad5a 100644 --- a/drivers/media/dvb-frontends/lgdt3306a.c +++ b/drivers/media/dvb-frontends/lgdt3306a.c @@ -2176,6 +2176,11 @@ static int lgdt3306a_probe(struct i2c_client *client) struct dvb_frontend *fe; int ret; + if (!client->dev.platform_data) { + dev_err(&client->dev, "platform data is mandatory\n"); + return -EINVAL; + } + config = kmemdup(client->dev.platform_data, sizeof(struct lgdt3306a_config), GFP_KERNEL); if (config == NULL) { -- 2.43.0