From de8a895d4b40b7a0e2cc355a9af31deb12a8a001 Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Sat, 29 Nov 2008 01:23:59 +0000 Subject: Fix a possible NULL pointer dereference. Spotted by Tobias Ulmer; thanks! --- sys/dev/pci/drm/drmP.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h index 7f4fe148735..d36eed410f3 100644 --- a/sys/dev/pci/drm/drmP.h +++ b/sys/dev/pci/drm/drmP.h @@ -148,7 +148,8 @@ enum { #define DRM_AGP_MEM struct agp_memory_info /* D_CLONE only supports one device, this will be fixed eventually */ -#define drm_get_device_from_kdev(_kdev) drm_cd.cd_devs[0] +#define drm_get_device_from_kdev(_kdev) \ + (drm_cd.cd_ndevs > 0 ? drm_cd.cd_devs[0] : NULL) #if 0 #define drm_get_device_from_kdev(_kdev) \ (minor(_kdev) < drm_cd.cd_ndevs) ? drm_cd.cd_devs[minor(_kdev)] : NULL -- cgit v1.2.3