Skip to contentSkip to conversation

drm/msm: don't deref error pointer in the msm_fbdev_create error path

PATCH Superseded Emil Velikov 1 participant 3 messages Mar 28, 2018 – Apr 3, 2018 2 messages not in the archive

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

PATCH 1/1 drm/msm: don't deref error pointer in the msm_fbdev_create error path

From: Emil Velikov <[email protected]>

Currently the error pointer returned by msm_alloc_stolen_fb gets passed to drm_framebuffer_remove. The latter handles only NULL pointers, thus a nasty crash will occur.

Drop the unnecessary fail label and the associated checks - both err and fb will be set at this stage.

---
 drivers/gpu/drm/msm/msm_fbdev.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/gpu/drm/msm/msm_fbdev.c +2 -7
index c178563fcd4d..6ed89bcfedf5 100644
@@ -92,8 +92,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 
 	if (IS_ERR(fb)) {
 		dev_err(dev->dev, "failed to allocate fb\n");
-		ret = PTR_ERR(fb);
-		goto fail;
+		return PTR_ERR(fb);
 	}
 
 	bo = msm_framebuffer_bo(fb, 0);
@@ -153,11 +152,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 	mutex_unlock(&dev->struct_mutex);
 fail:
 
-	if (ret) {
-		if (fb)
-			drm_framebuffer_remove(fb);
-	}
-
+	drm_framebuffer_remove(fb);
 	return ret;
 }
 
Signature · 6 lines
2.16.0

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20180328155347.7472-1-emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH v2 1/1 drm/msm: don't deref error pointer in the msm_fbdev_create error path

From: Emil Velikov <[email protected]>

Currently the error pointer returned by msm_alloc_stolen_fb gets passed to drm_framebuffer_remove. The latter handles only NULL pointers, thus a nasty crash will occur.

Drop the unnecessary fail label and the associated checks - both err and fb will be set at this stage.

---
v2: really remove the fail label :-\

---
 drivers/gpu/drm/msm/msm_fbdev.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/msm_fbdev.c +2 -9
index c178563fcd4d..456622b46335 100644
@@ -92,8 +92,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 
 	if (IS_ERR(fb)) {
 		dev_err(dev->dev, "failed to allocate fb\n");
-		ret = PTR_ERR(fb);
-		goto fail;
+		return PTR_ERR(fb);
 	}
 
 	bo = msm_framebuffer_bo(fb, 0);
@@ -151,13 +150,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
 
 fail_unlock:
 	mutex_unlock(&dev->struct_mutex);
-fail:
-
-	if (ret) {
-		if (fb)
-			drm_framebuffer_remove(fb);
-	}
-
+	drm_framebuffer_remove(fb);
 	return ret;
 }
 
Signature · 6 lines
2.16.0

_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno

A message that is not in the archive (sent off-list or not yet received): 20180328162216.8595-1-emil.l.velikov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 9 lines · Emil Velikov

From: Emil Velikov <[email protected]>

Currently the error pointer returned by msm_alloc_stolen_fb gets passed to drm_framebuffer_remove. The latter handles only NULL pointers, thus a nasty crash will occur.

Drop the unnecessary fail label and the associated checks - both err and fb will be set at this stage.

Quoted 8 lines

---
v2: really remove the fail label :-\
---

Humble ping?

-Emil
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno