Skip to contentSkip to conversation

drm_crtc: check if fb_create return NULL

PATCH RESEND Superseded Su, Xuemin 2 participants 3 messages Jan 23, 2013 – Jan 24, 2013

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Su, Xuemin

author
#0 lore raw

PATCH RESEND v2 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 |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +7 -0
index f2d667b..b748498 100644
@@ -2172,6 +2172,13 @@ 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 */
+	if (!fb) {
+		WARN(1, "%pf should not return NULL.",
+			dev->mode_config.funcs->fb_create);
+		ret = -EINVAL;
+		goto out;
+	}
 
 	or->fb_id = fb->base.id;
 	list_add(&fb->filp_head, &file_priv->fbs);
Signature · 1 line
1.7.6
#1 lore raw
Quoted 8 lines · Xuemin

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.

Imo just BUG_ON(!fb); and call it a day. Makes it pretty clear what's expected of the drivers.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
author
#2 lore raw

-----Original Message-----

Quoted 8 lines

From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Wednesday, January 23, 2013 5:54 PM
To: Su, Xuemin
Cc: [email protected]; [email protected]; [email protected]; [email protected]; He, Bo
Subject: Re: [PATCH V2 RESEND] drm_crtc: check if fb_create return NULL

Imo just BUG_ON(!fb); and call it a day. Makes it pretty clear what's expected of the drivers. -Daniel

Thanks, I will upload PATCH V3.
Xuemin