
From: Yuanjun Gong ruc_gongyuanjun@163.com
[ 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 ruc_gongyuanjun@163.com Link: https://patch.msgid.link/20250513123744.3041724-1-ruc_gongyuanjun@163.com Signed-off-by: Mark Brown broonie@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
**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 99683f292b5d8..ae4965a9f7649 100644 --- a/sound/soc/tegra/tegra210_ahub.c +++ b/sound/soc/tegra/tegra210_ahub.c @@ -1359,6 +1359,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);