diff mbox

Gpu: drm: tegra - Fix possible NULL derefrence.

Message ID 1485752025-29465-1-git-send-email-shailendra.v@samsung.com
State Rejected
Headers show

Commit Message

Shailendra Verma Jan. 30, 2017, 4:53 a.m. UTC
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/gpu/drm/tegra/sor.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Thierry Reding Jan. 30, 2017, 7:11 a.m. UTC | #1
On Mon, Jan 30, 2017 at 10:23:45AM +0530, Shailendra Verma wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.
> 
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
>  drivers/gpu/drm/tegra/sor.c |    4 ++++
>  1 file changed, 4 insertions(+)

No, this will never happen on Tegra. If you reach the ->probe() function
this pointer is guaranteed to be non-NULL.

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 74d0540..34f032f 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -2540,6 +2540,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, "Error: No device match found\n");
+		return -ENODEV;
+	}
 
 	sor = devm_kzalloc(&pdev->dev, sizeof(*sor), GFP_KERNEL);
 	if (!sor)