drm_crtc: check if fb_create return NULL
Subsystems (2)
PATCH v3 1/1 drm_crtc: check if fb_create return NULL
From: xueminsu <[email protected]>
Date: Tue, 22 Jan 2013 22:39:39 +0800
Subject: [PATCH] drm_crtc: check if fb_create return NULL
Some buggy driver may still return NULL in fb_create, which leads to kernel panic.
--- drivers/gpu/drm/drm_crtc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +2 -0
@@ -2172,6 +2172,8 @@ int drm_mode_addfb(struct drm_device *dev, ret =PTR_ERR (fb); goto out; } +/* some buggy driver may return NULL here, which may cause panic */ +BUG_ON (!fb); or->fb_id = fb->base.id;list_add (&fb->filp_head, &file_priv->fbs);
Signature · 1 line
1.7.6
Quoted 17 lines · Xuemin
From: xueminsu <[email protected]>
Date: Tue, 22 Jan 2013 22:39:39 +0800
Subject: [PATCH]drm_crtc: check iffb_createreturn NULLSome buggy driver may still return NULL in
fb_create, which leads to kernel panic.Signed-off-by xueminsu <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c int drm_mode_addfb(struct drm_device *dev, · line 2176
Quoted 5 lines
drivers/gpu/drm/drm_crtc.c +2
-0@@ -2172,6 +2172,8 @@ int drm_mode_addfb(struct drm_device *dev, ret =PTR_ERR (fb); goto out; } +/* some buggy driver may return NULL here, which may cause panic */ +BUG_ON (!fb);
I fail to see the benefit of this compared to just letting it oops...
drivers/gpu/drm/drm_crtc.c int drm_mode_addfb(struct drm_device *dev, · line 2178
Quoted 1 line
drivers/gpu/drm/drm_crtc.c +0
-0or->fb_id = fb->base.id;
...right here.
BR,
Jani.
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +0
-0list_add (&fb->filp_head, &file_priv->fbs);Signature · 8 lines
1.7.6 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 11 lines · Jani Nikula
drivers/gpu/drm/drm_crtc.c int drm_mode_addfb(struct drm_device *dev, · line 2176
Quoted 3 lines
drivers/gpu/drm/drm_crtc.c +2
-0} +/* some buggy driver may return NULL here, which may cause panic */ +BUG_ON (!fb);I fail to see the benefit of this compared to just letting it oops...
Quoted 1 line
or->fb_id=fb->base.id;...right here.
For PATCH V3, I think a BUG_ON may give the user clearer information about the reason of panic. Easier to debug.
I submitted a PATCH V2 yesterday which gives a warning and then return -EVAL if fb==NULL, preventing the panic. Do you think this is acceptable?
Jani Nikula
Reviewed-byQuoted 7 lines · Xuemin
Quoted 6 lines · Jani Nikula
drivers/gpu/drm/drm_crtc.c int drm_mode_addfb(struct drm_device *dev, · line 2176
Quoted 3 lines
drivers/gpu/drm/drm_crtc.c +2
-0} +/* some buggy driver may return NULL here, which may cause panic */ +BUG_ON (!fb);I fail to see the benefit of this compared to just letting it oops...
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
or->fb_id=fb->base.id;...right here.
For PATCH V3, I think a
BUG_ONmay give the user clearer information about the reason of panic. Easier to debug.
Ah, sorry, never mind, I missed Daniel's comment. The benefit of the BUG_ON() is making it clear what's expected of the drivers.
-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Thursday, January 24, 2013 5:05 PM
To: Su, Xuemin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; He, Bo
Subject: Re: [PATCH V3] drm_crtc: check if fb_create return NULL
Quoted 4 lines
Ah, sorry, never mind, I missed Daniel's comment. The benefit of the
BUG_ON()is making it clear what's expected of the drivers.Reviewed-by Jani Nikula <[email protected]>
Do you think this patch is still needed?
Currently I fix a buggy function radeon_user_framebuffer_create() which returns NULL and patch is added to 3.7-stable tree. Do you think it's also needed to do something in drm_mode_addfb()?
Thanks.
Quoted 7 lines · Xuemin
-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Thursday, January 24, 2013 5:05 PM
To: Su, Xuemin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; He, Bo
Subject: Re: [PATCH V3]drm_crtc: check iffb_createreturn NULL
Quoted 8 lines
Quoted 4 lines
Ah, sorry, never mind, I missed Daniel's comment. The benefit of the
BUG_ON()is making it clear what's expected of the drivers.Reviewed-by Jani Nikula <[email protected]>Do you think this patch is still needed?
Currently I fix a buggy functionradeon_user_framebuffer_create()which returns NULL and patch is added to 3.7-stable tree. Do you think it's also needed to do something indrm_mode_addfb()?
Imo it's still useful, just to document the assumptions of the interface. Dave? -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch