Skip to contentSkip to conversation

drm/tegra: sor: add NULL check on of_match_device() return value

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Jul 7, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tegra: sor: add NULL check on of_match_device() return value

Check return value from call to of_match_device()
in order to prevent a NULL pointer dereference.

In case of NULL print error message and return.

---
 drivers/gpu/drm/tegra/sor.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/tegra/sor.c +4 -0
index a8f5289..ca3d9b1 100644
@@ -2538,6 +2538,10 @@ static int tegra_sor_probe(struct platform_device *pdev)
 	int err;
 
 	match = of_match_device(tegra_sor_of_match, &pdev->dev);
+	if (!match) {
+		dev_err(&pdev->dev, "failed to match device\n");
+		return -ENODEV;
+	}
 
 	sor = devm_kzalloc(&pdev->dev, sizeof(*sor), GFP_KERNEL);
 	if (!sor)
Signature · 1 line
2.5.0
maintainer
#1 lore raw
Quoted 15 lines · Gustavo A. R. Silva

Check return value from call to of_match_device()
in order to prevent a NULL pointer dereference.

In case of NULL print error message and return.

---
 drivers/gpu/drm/tegra/sor.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpu/drm/tegra/sor.c +0 -0
index a8f5289..ca3d9b1 100644

drivers/gpu/drm/tegra/sor.c static int tegra_sor_probe(struct platform_device *pdev) · line 2544

Quoted 7 lines
drivers/gpu/drm/tegra/sor.c +4 -0
@@ -2538,6 +2538,10 @@ static int tegra_sor_probe(struct platform_device *pdev)
 	int err;
 
 	match = of_match_device(tegra_sor_of_match, &pdev->dev);
+	if (!match) {
+		dev_err(&pdev->dev, "failed to match device\n");
+		return -ENODEV;
+	}

Given that Tegra always uses device-tree, I believe that this cannot happen and so this additional check is not needed.

Jon

Signature · 5 lines
nvpublic
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel