Skip to contentSkip to conversation

Fix NULL-reference in DRM

PATCH New Takashi Iwai 1 participant 1 message Nov 30, 2005 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix NULL-reference in DRM

This patch fixes the NULL pointer reference in DRM.
SiS driver tries to allocate a big chunk of memory, but the return value is never checked.

Reported in Novell bugzilla #132271:
https://bugzilla.novell.com/show_bug.cgi?id=132271

From: Egbert Eich <[email protected]>

drivers/char/drm/drm_context.c +4 -1
@@ -432,7 +432,10 @@ int drm_addctx(struct inode *inode, stru
 
 	if (ctx.handle != DRM_KERNEL_CONTEXT) {
 		if (dev->driver->context_ctor)
-			dev->driver->context_ctor(dev, ctx.handle);
+			if (!dev->driver->context_ctor(dev, ctx.handle)) {
+				DRM_DEBUG( "Running out of ctxs or memory.\n");
+				return -ENOMEM;
+			}
 	}
 
 	ctx_entry = drm_alloc(sizeof(*ctx_entry), DRM_MEM_CTXLIST);