Skip to contentSkip to conversation

nouveau: need to handle failed allocation

PATCH In review Insu Yun 3 participants 4 messages Jan 29, 2016

Subsystems (3)
lore
Share & tools
lore

Insu Yun

author
#0 lore raw

PATCH 1/1 nouveau: need to handle failed allocation

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

---
 drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_display.c +6 -0
index 24be27d..26b4902 100644
@@ -443,6 +443,12 @@ nouveau_display_create_properties(struct drm_device *dev)
 	/* -100..+100 */
 	disp->color_vibrance_property =
 		drm_property_create_range(dev, 0, "color vibrance", 0, 200);
+
+	if (!disp->underscan_hborder_property ||
+			!disp->underscan_vborder_property ||
+			!disp->vibrant_hue_property ||
+			!disp->color_vibrance_property)
+		return;
 }
 
 int
Signature · 1 line
1.9.1
#1 lore raw
Quoted 13 lines · Insu Yun

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

---
 drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/nouveau/nouveau_display.c +0 -0
index 24be27d..26b4902 100644

drivers/gpu/drm/nouveau/nouveau_display.c nouveau_display_create_properties(struct drm_device *dev) · line 451

Quoted 9 lines
drivers/gpu/drm/nouveau/nouveau_display.c +6 -0
@@ -443,6 +443,12 @@ nouveau_display_create_properties(struct drm_device *dev)
        /* -100..+100 */
        disp->color_vibrance_property =
                drm_property_create_range(dev, 0, "color vibrance", 0, 200);
+
+       if (!disp->underscan_hborder_property ||
+                       !disp->underscan_vborder_property ||
+                       !disp->vibrant_hue_property ||
+                       !disp->color_vibrance_property)
+               return;

Aren't we at the end of the function anyways?

Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_display.c +0 -1
 }
 
 int
--

1.9.1

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

author
#2 lore raw
Quoted 20 lines · Ilia Mirkin

Review

Quoted 9 lines · Insu Yun

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

---
 drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++++++
 1 file changed, 6 insertions(+)
(quoted diff) +0 -0

b/drivers/gpu/drm/nouveau/nouveau_display.c

drivers/gpu/drm/nouveau/nouveau_display.c nouveau_display_create_properties(struct drm_device

Quoted 4 lines

index 24be27d..26b4902 100644

drivers/gpu/drm/nouveau/nouveau_display.c +0 -0
@@ -443,6 +443,12 @@ nouveau_display_create_properties(struct drm_device

*dev)

drivers/gpu/drm/nouveau/nouveau_display.c nouveau_display_create_properties(struct drm_device *dev)

Quoted 3 lines
drivers/gpu/drm/nouveau/nouveau_display.c +0 -0
        /* -100..+100 */
        disp->color_vibrance_property =
                drm_property_create_range(dev, 0, "color vibrance", 0,

200);

Quoted 9 lines

drivers/gpu/drm/nouveau/nouveau_display.c nouveau_display_create_properties(struct drm_device *dev) · line 451

Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_display.c +6 -0
+
+       if (!disp->underscan_hborder_property ||
+                       !disp->underscan_vborder_property ||
+                       !disp->vibrant_hue_property ||
+                       !disp->color_vibrance_property)
+               return;

Aren't we at the end of the function anyways?

Sorry. it is not perfect patch
I found this by my static analyzer.
I have limited knowledge about this driver. I don't want to mass up your driver. What I want to do is to tell you there is a bug. I think we need to return error to caller.

Quoted 8 lines
Quoted 7 lines
drivers/gpu/drm/nouveau/nouveau_display.c +0 -1
 }
 
 int
--

1.9.1

Signature · 2 lines
Regards
Insu Yun

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

#3 lore raw
Quoted 32 lines · Insu Yun

On Thu, Jan 28, 2016 at 7:08 PM, Ilia Mirkin <[email protected] <mailto:[email protected]>> wrote:

    On Thu, Jan 28, 2016 at 7:09 PM, Insu Yun <[email protected]
    <mailto:[email protected]>> wrote:
    > drm_property_create_range can be failed in memory pressure.
    > So, it needs to be handled.
    >
    > Signed-off-by: Insu Yun <[email protected] <mailto:[email protected]>>
    > ---
    >  drivers/gpu/drm/nouveau/nouveau_display.c | 6 ++++++
    >  1 file changed, 6 insertions(+)
    >
    > diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
    > index 24be27d..26b4902 100644
    > --- a/drivers/gpu/drm/nouveau/nouveau_display.c
    > +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
    > @@ -443,6 +443,12 @@ nouveau_display_create_properties(struct drm_device *dev)
    >         /* -100..+100 */
    >         disp->color_vibrance_property =
    >                 drm_property_create_range(dev, 0, "color vibrance", 0, 200);
    > +
    > +       if (!disp->underscan_hborder_property ||
    > +                       !disp->underscan_vborder_property ||
    > +                       !disp->vibrant_hue_property ||
    > +                       !disp->color_vibrance_property)
    > +               return;

    Aren't we at the end of the function anyways?
Quoted 6 lines

Sorry. it is not perfect patch
I found this by my static analyzer.
I have limited knowledge about this driver. I don't want to mass up your driver. What I want to do is to tell you there is a bug. I think we need to return error to caller.

I'm not so sure we do. We check for valid pointers for these when they're actually used, so no OOPS will occur. Worst case, the driver still loads correctly with some missing properties.

Ben.

Quoted 16 lines
Quoted 9 lines

}

int
--
1.9.1

Signature · 2 lines
Regards
Insu Yun

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