[PATCH] SiS DRM: Fix possible NULL dereference
authorEgbert Eich <eich@suse.de>
Wed, 30 Nov 2005 14:32:59 +0000 (15:32 +0100)
committerLinus Torvalds <torvalds@g5.osdl.org>
Wed, 30 Nov 2005 16:45:40 +0000 (08:45 -0800)
This fixes a NULL pointer reference in DRM.  The 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

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/char/drm/drm_context.c

index bdd168d88f49b0ab6a0103f6c32b20e4fde46105..bd958d69a2ac2aeccb166739c83de1cb674fa4cc 100644 (file)
@@ -432,7 +432,10 @@ int drm_addctx(struct inode *inode, struct file *filp,
 
        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);