[PATCH v2 2/3] pwm: tegra: Check for match_data being NULL

From: Uwe Kleine-König

Date: Fri Sep 18 2026 - 11:29:42 EST


It's unlikely but not impossible that of_device_get_match_data() returns
NULL. Handle this case instead of triggering a NULL pointer exception.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
---
drivers/pwm/pwm-tegra.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/drivers/pwm/pwm-tegra.c b/drivers/pwm/pwm-tegra.c
index efb7ab60f602..b461d3877f43 100644
--- a/drivers/pwm/pwm-tegra.c
+++ b/drivers/pwm/pwm-tegra.c
@@ -323,6 +323,14 @@ static int tegra_pwm_probe(struct platform_device *pdev)
int ret;

soc = of_device_get_match_data(dev);
+ if (!soc) {
+ /*
+ * This can only happen if pdev was matched via pdev->name
+ * (which should not happen today) or in combination with a
+ * driver override.
+ */
+ return dev_err_probe(dev, -ENODEV, "Unsupported device\n");
+ }

chip = devm_pwmchip_alloc(dev, soc->num_channels, sizeof(*pc));
if (IS_ERR(chip))
--
2.47.3