drm/r128: Add test for initialisation to all ioctls that require it
commitc855efe3b0b6d38df11e7773abf3c4c46af126ad
authorBen Hutchings <ben@decadent.org.uk>
Sun, 23 Aug 2009 15:59:04 +0000 (23 16:59 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 1 Apr 2010 22:55:52 +0000 (1 15:55 -0700)
treed699ee7ae46b1dea04331ca0460115fbd3fa5de4
parent1161237e66e5530a5e473fe40105cc727c6ed770
drm/r128: Add test for initialisation to all ioctls that require it

commit 7dc482dfeeeefcfd000d4271c4626937406756d7 upstream.

Almost all r128's private ioctls require that the CCE state has
already been initialised.  However, most do not test that this has
been done, and will proceed to dereference a null pointer.  This may
result in a security vulnerability, since some ioctls are
unprivileged.

This adds a macro for the common initialisation test and changes all
ioctl implementations that require prior initialisation to use that
macro.

Also, r128_do_init_cce() does not test that the CCE state has not
been initialised already.  Repeated initialisation may lead to a crash
or resource leak.  This adds that test.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/gpu/drm/r128/r128_cce.c
drivers/gpu/drm/r128/r128_drv.h
drivers/gpu/drm/r128/r128_state.c