Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2139151lqb; Mon, 27 May 2024 09:03:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6WQ1GtzAiDRiPTRXa8BboZ4BOHSqCqesjOWtCMBPNPjz4X+Mpnqb7CctxuoqRHFSjnW2I/ucx8a6o8hDYfig6KliLk7OqifcBUUj4gw== X-Google-Smtp-Source: AGHT+IFP14VumZCwF8kmRiTs1j4AxqHQrkqQ+mln9lWq/GQV+1PydX/Jk0euDpwimvVpE1LDzHxd X-Received: by 2002:a17:906:da04:b0:a62:129e:e693 with SMTP id a640c23a62f3a-a6265114ac6mr659002666b.52.1716825811373; Mon, 27 May 2024 09:03:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716825811; cv=pass; d=google.com; s=arc-20160816; b=J5zHW57kVGI9Z9ONIxC045JgW1HI0+6CA90HWT1mXHkpsL3R4Wn4LYW5kiUrf4qGOt NSLXVi+0WpjbPPGszitZ4yb41hl0KKLlAJba3oyGN5amntd62u/QdgKiBNlfrbCvgAmJ Vg7IWKxEY9ONjiWccAEMGPAKniax341UpzFWXAXiYxBk0f6cORzjZ8ma0QgtwUdDQ9V5 BDDgAtuWbediDkOiCFvdi6ot+j0inVuzsaqPYvuy+PrZDw7IuXuo6Pf+ef1cbx03meRh WKq/tEDqwZ2iRM3YoX2fz0cTNTve9GxOLvQMCCFwHITNDDW8tD9AXI5A2cfcbP2NKngp oLYQ== 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=4vnD9eBCeamaAd4EZadnKwZ8UuEBcEevC55wCxGzotI=; b=k2jPWf6UpHmY54XYDNJa0cXrpUEuTIXxFQs1ukWetnqwmgdCIJ7pyGdCUccf7zXMTC yd/uzaqTXbFtSTibQroLF3qusCMqGCEIO7g5DBgB86dhUu5C9pmHQmAqU6pFhytLTq1r D9vK3WJ1iRyfaNchWo6wNk/UgL692hSBTWqmKjMSYtTLb99gVzIi7P38EGy1IENzJse0 8iE445JHpzyQiZZQQoB2trQBWDOAIt/Po31kQp3Dqw5OMK51NN+F4v6eFNTwEzNDk2Ar bMwinwH3K0vCbEWknBKS0rBPCazhiFXL52C/wVoiL9lyGjnsCYeRcsUv4abiZNMbUILv sO6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mwY2Osjz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191152-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cdd37a0si403773366b.995.2024.05.27.09.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 09:03:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mwY2Osjz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-191152-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191152-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3EE101F230A4 for ; Mon, 27 May 2024 16:03:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 94F4216C6BA; Mon, 27 May 2024 15:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mwY2Osjz" 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 B755816C6AC; Mon, 27 May 2024 15:56:19 +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=1716825379; cv=none; b=W0IoY5tFFcjP42Lt1zh0p9/sDpxfnZdh3nHXqt8e4Rtt6uMyH57l2l+q8Err3F8j8odj01Kzvq/zpwdnrlgcDmt/GPSCNiAht5UtsSkNd5K7NOGjRDCKZO2hbs1EhzzAjtVGas5EUzv6i8eGw5uLJcGwgw4gb27UvAN23GErlak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716825379; c=relaxed/simple; bh=Tw3zDUMJPnwZjnIYo1ORXpO1GQ+JnxUHJ0CmsdPjWLw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFiWMH+3bT9eBHRwpwazEKidsMrufps8WpbW1FgtCAoAL+gg1MqxTha5gzH3HRSoudqNZgCp8DWxMDSayT2DqcDEJcS5j0xgXjuBuOvJ//JurWbcu9+wVaDjsQy0NGl9lFdMrx4HEFJrG01rz7xxs0cGQ/KHZeYcopCfJYtl1Bo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mwY2Osjz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 677AEC2BBFC; Mon, 27 May 2024 15:56:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716825379; bh=Tw3zDUMJPnwZjnIYo1ORXpO1GQ+JnxUHJ0CmsdPjWLw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mwY2OsjzXiCoHd1jYaaH37z6hehKZg4dRraVv0xI0+eAxWwI4Z9bverKbT1+DYx6s tbyuGo+ccc08AMK1xhSOcWjoLNGmzWDQTJBMm7sNbefrM71qXr6GKqct1Y6XanEmmJ G+VdyFYFvbc3jCV8iumbGqlJCKu4hQpSjAVbTc3HF7GYO+9vGF2Ek0cbeKx+FKBHFj cmgO0ZIW36U20yw/y4JbuoY3cinU4nmAuQnP/GL7U4x3K74FP8wJzf06FqNyliiQAO FnLoON3iijhnv6hGAr/2HqTAylNSEFKip6RegLnDPTG4BZjXHyNYzB7dYK7AablIxS MrswHR1tMocjA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zheyu Ma , Mauro Carvalho Chehab , Sasha Levin , mcgrof@kernel.org, andriy.shevchenko@linux.intel.com, tzimmermann@suse.de, hkallweit1@gmail.com, gregkh@linuxfoundation.org, linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 10/16] media: lgdt3306a: Add a check against null-pointer-def Date: Mon, 27 May 2024 11:55:01 -0400 Message-ID: <20240527155541.3865428-10-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240527155541.3865428-1-sashal@kernel.org> References: <20240527155541.3865428-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.6.32 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