From mboxrd@z Thu Jan 1 00:00:00 1970 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 26FD127E1AB; Fri, 30 May 2025 12:42:00 +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=1748608920; cv=none; b=go3tLuyLv9REFE2yRSyiLLkQglhiubcv2ZJXJ6rAJz7Yoh1XMkKZG/NoHacd8OffxzsgPFGR0JuM5n+8wqr+DWQqAVUTvmue06CxGIMPJI1zOwNq7CPlGvpxoym9+ZuOu3okMx9uNFx2Ap+JfoOfrQ0u9cZ+zarSvTNfTkeod/A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1748608920; c=relaxed/simple; bh=SumBUkfrG0wtiXyJpufWgfiVWH6WVko4x6bFVrjMH5Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=IchVrHmEaH3qj6sAVRzHFFkPA0hCihVert8sqwW7FJ/ckYSiFmowjd1/TGU2s+RUdH9UNVRNKMET8YT2DpGJG/kUOhiFBDD4LLPzeNQSbBXIrLc5UfVHL04u0hiJDb0lSw64SzJPwmRc8OJ3MIJ2bXC3Ua5IjKOr55m+WgsYifg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NeC7whn8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NeC7whn8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8C67C4CEE9; Fri, 30 May 2025 12:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1748608920; bh=SumBUkfrG0wtiXyJpufWgfiVWH6WVko4x6bFVrjMH5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NeC7whn8F853I4IKmleFBufFOSaWENFYe1bEYHUB7ARmTzhBDzz+WGM0LvVRyhNxv GmmKcCt0G/dj7QQ1/F1SqsPUhk4xuZEhxI8h1Ww7DGSAg98rmKuugy2O6ev9OfGP3j TviNsPyYqZlc+G09dChxl7F3Q3hkEYAZtM6PeSIvJZ+mZe7bKObLWlEcpJ5iz2DD3b zIeGTFoxA7NZ2cm0mspxQEupz/h+lviqcmXCFJyBKhZrhm40F7HY4FhHO3wtQtSS7y fbvIgX47hRhle0vA04o/u8Tk/iHXH0Q5rAzWxH9+CpE2z/wXCQoUQZFgY/wLHzAz0n GW3PPdwfTR6Fw== From: Sasha Levin To: patches@lists.linux.dev, stable@vger.kernel.org Cc: Yuanjun Gong , Mark Brown , Sasha Levin , lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, thierry.reding@gmail.com, jonathanh@nvidia.com, alsa-devel@alsa-project.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 08/10] ASoC: tegra210_ahub: Add check to of_device_get_match_data() Date: Fri, 30 May 2025 08:41:46 -0400 Message-Id: <20250530124148.2576913-8-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250530124148.2576913-1-sashal@kernel.org> References: <20250530124148.2576913-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.237 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yuanjun Gong [ Upstream commit 04cb269c204398763a620d426cbee43064854000 ] In tegra_ahub_probe(), check the result of function of_device_get_match_data(), return an error code in case it fails. Signed-off-by: Yuanjun Gong Link: https://patch.msgid.link/20250513123744.3041724-1-ruc_gongyuanjun@163.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- **YES** This commit should be backported to stable kernel trees. **Extensive Analysis:** **1. Nature of the Bug Fix:** This commit fixes a critical null pointer dereference vulnerability in the tegra210_ahub driver. The code calls `of_device_get_match_data(&pdev->dev)` but never validates the return value before using `ahub->soc_data`. Looking at the kernel tree, we can see that immediately after the assignment, the code accesses `ahub->soc_data->regmap_config` and later `ahub->soc_data->cmpnt_drv`, `ahub->soc_data->dai_drv`, and `ahub->soc_data->num_dais` without any null checking. **2. Severity and Impact:** - **High severity**: A null pointer dereference in the kernel probe function can cause kernel panic - **User impact**: Systems using Tegra210 audio hardware could crash during device initialization - **Subsystem criticality**: Audio subsystem failure affects multimedia functionality **3. Code Analysis:** The fix is minimal and surgical: ```c ahub->soc_data = of_device_get_match_data(&pdev->dev); +if (!ahub->soc_data) + return -ENODEV; ``` This follows established kernel patterns and returns an appropriate error code (-ENODEV) when device match data cannot be found. **4. Consistency with Similar Fixes:** Examining the kernel tree reveals that other Tegra drivers have already been fixed with identical patterns: - `tegra30_ahub.c` already has this null check (returns -EINVAL) - `tegra30_i2s.c` already has this null check (returns -ENODEV) This indicates that tegra210_ahub was an oversight that should be corrected for consistency and safety. **5. Historical Reference Analysis:** While the provided historical commits all have "Backport Status: NO", they were primarily code cleanup and API migration commits (switching to `of_device_get_match_data`), not security/stability fixes. This commit is fundamentally different - it's a critical bug fix that prevents kernel crashes. **6. Stable Tree Criteria Compliance:** - ✅ **Important bugfix**: Prevents kernel panic - ✅ **Minimal risk**: Two-line addition with well-established pattern - ✅ **Small and contained**: No architectural changes - ✅ **Clear purpose**: Prevents null pointer dereference - ✅ **Subsystem confined**: Only affects tegra210_ahub driver **7. Risk Assessment:** - **Regression risk**: Extremely low - only adds a safety check - **Side effects**: None - failure case now returns clean error instead of crashing - **Testing impact**: Improves robustness without changing successful code paths **Conclusion:** This is a textbook example of a commit that should be backported to stable trees. It fixes a critical null pointer dereference that can cause kernel panics, uses minimal code changes following established patterns, and has virtually no risk of introducing regressions. The fix brings tegra210_ahub in line with other Tegra drivers that already have this protection. sound/soc/tegra/tegra210_ahub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/tegra/tegra210_ahub.c b/sound/soc/tegra/tegra210_ahub.c index 1b2f7cb8c6adc..686c8ff46ec8a 100644 --- a/sound/soc/tegra/tegra210_ahub.c +++ b/sound/soc/tegra/tegra210_ahub.c @@ -607,6 +607,8 @@ static int tegra_ahub_probe(struct platform_device *pdev) return -ENOMEM; ahub->soc_data = of_device_get_match_data(&pdev->dev); + if (!ahub->soc_data) + return -ENODEV; platform_set_drvdata(pdev, ahub); -- 2.39.5