From: xueminsu xuemin.su@intel.com 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.
Signed-off-by: xueminsu xuemin.su@intel.com --- drivers/gpu/drm/drm_crtc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index f2d667b..ae613ec 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -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);
On Thu, 24 Jan 2013, "Su, Xuemin" xuemin.su@intel.com wrote:
From: xueminsu xuemin.su@intel.com 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.
Signed-off-by: xueminsu xuemin.su@intel.com
drivers/gpu/drm/drm_crtc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index f2d667b..ae613ec 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -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...
or->fb_id = fb->base.id;
...right here.
BR, Jani.
list_add(&fb->filp_head, &file_priv->fbs);
1.7.6
dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel
On Thu, 2013-01-24 at 10:31 +0200, Jani Nikula wrote:
}
- /* 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...
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?
On Thu, 24 Jan 2013, "Su, Xuemin" xuemin.su@intel.com wrote:
On Thu, 2013-01-24 at 10:31 +0200, Jani Nikula wrote:
}
- /* 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...
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.
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 jani.nikula@intel.com
-----Original Message----- From: Jani Nikula [mailto:jani.nikula@linux.intel.com] Sent: Thursday, January 24, 2013 5:05 PM To: Su, Xuemin Cc: airlied@linux.ie; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; yanmin_zhang@linux.intel.com; He, Bo Subject: Re: [PATCH V3] drm_crtc: check if fb_create return NULL
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 jani.nikula@intel.com
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.
On Thu, Jan 31, 2013 at 1:55 AM, Su, Xuemin xuemin.su@intel.com wrote:
-----Original Message----- From: Jani Nikula [mailto:jani.nikula@linux.intel.com] Sent: Thursday, January 24, 2013 5:05 PM To: Su, Xuemin Cc: airlied@linux.ie; dri-devel@lists.freedesktop.org; linux-kernel@vger.kernel.org; yanmin_zhang@linux.intel.com; He, Bo Subject: Re: [PATCH V3] drm_crtc: check if fb_create return NULL
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 jani.nikula@intel.com
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()?
Imo it's still useful, just to document the assumptions of the interface. Dave? -Daniel
dri-devel@lists.freedesktop.org