Skip to contentSkip to conversation

gma500: handling failed allocation

PATCH NAK Insu Yun 2 participants 3 messages Jan 29, 2016

Subsystems (3)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 gma500: handling failed allocation

Since drm_property_create_range can be failed in memory pressure, it needs to be handled.

---
 drivers/gpu/drm/gma500/framebuffer.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/gma500/framebuffer.c +2 -0
index cb95765..31085e4 100644
@@ -683,6 +683,8 @@ static int psb_create_backlight_property(struct drm_device *dev)
 		return 0;
 
 	backlight = drm_property_create_range(dev, 0, "backlight", 0, 100);
+	if (!backlight)
+		return -ENOMEM;
 
 	dev_priv->backlight_property = backlight;
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 13 lines · On Thu, 28 Jan 2016 19:05:16 -0500 Insu Yun <[email protected]> wrote:

Since drm_property_create_range can be failed in memory pressure, it needs to be handled.

---
 drivers/gpu/drm/gma500/framebuffer.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/gma500/framebuffer.c +0 -0
index cb95765..31085e4 100644

drivers/gpu/drm/gma500/framebuffer.c static int psb_create_backlight_property(struct drm_device *dev) · line 690

Quoted 8 lines
drivers/gpu/drm/gma500/framebuffer.c +2 -0
@@ -683,6 +683,8 @@ static int psb_create_backlight_property(struct drm_device *dev)
 		return 0;
 
 	backlight = drm_property_create_range(dev, 0, "backlight", 0, 100);
+	if (!backlight)
+		return -ENOMEM;
 
 	dev_priv->backlight_property = backlight;
 

NAK.

If we fail to create the backlight we are better off continuing than failing. The user just loses backlight control rather than having no display at all.

If you check the callers you'll notice that the only caller doesn't even check the return code anyway so your patch is a no-op. If you are going to add error checking to anything with a patch please work back through the call chain and check the effect of the new error return - if any.

A better patch I think would be to just eliminate the function and turn it into a tiny bit of inlined code.

I'll send a patch to do that shortly.

Alan

author
#2 lore raw
Quoted 38 lines · One Thousand Gnomes

Review

Quoted 9 lines · On Thu, 28 Jan 2016 19:05:16 -0500 Insu Yun <[email protected]> wrote:

Since drm_property_create_range can be failed in memory pressure, it needs to be handled.

---
 drivers/gpu/drm/gma500/framebuffer.c | 2 ++
 1 file changed, 2 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/gma500/framebuffer.c

drivers/gpu/drm/gma500/framebuffer.c static int psb_create_backlight_property(struct

Quoted 4 lines

index cb95765..31085e4 100644

drivers/gpu/drm/gma500/framebuffer.c +0 -0
@@ -683,6 +683,8 @@ static int psb_create_backlight_property(struct

drm_device *dev)

drivers/gpu/drm/gma500/framebuffer.c static int psb_create_backlight_property(struct drm_device *dev) · line 690

Quoted 8 lines
drivers/gpu/drm/gma500/framebuffer.c +2 -0
              return 0;
 
      backlight = drm_property_create_range(dev, 0, "backlight", 0, 100);
+     if (!backlight)
+             return -ENOMEM;
 
      dev_priv->backlight_property = backlight;
 

NAK.

If we fail to create the backlight we are better off continuing than failing. The user just loses backlight control rather than having no display at all.

If you check the callers you'll notice that the only caller doesn't even check the return code anyway so your patch is a no-op. If you are going to add error checking to anything with a patch please work back through the call chain and check the effect of the new error return - if any.

Quoted 5 lines

A better patch I think would be to just eliminate the function and turn it into a tiny bit of inlined code.

I'll send a patch to do that shortly.

Thanks

Quoted 6 lines

Alan

Signature · 2 lines
Regards
Insu Yun

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel