drm/tegra: sor: add NULL check on of_match_device() return value
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.
Signed-off-by Gustavo A. R. Silva <[email protected]>
--- drivers/gpu/drm/tegra/sor.c | 4 ++++ 1 file changed, 4 insertions(+)
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 ; + } sor =devm_kzalloc (&pdev->dev,sizeof (*sor),GFP_KERNEL );if (!sor)
Signature · 1 line
2.5.0
Jon Hunter
maintainerQuoted 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.
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/gpu/drm/tegra/sor.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/tegra/sor.c +0
-0
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