summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
authorOwain Ainsworth <oga@cvs.openbsd.org>2008-11-29 01:23:59 +0000
committerOwain Ainsworth <oga@cvs.openbsd.org>2008-11-29 01:23:59 +0000
commitde8a895d4b40b7a0e2cc355a9af31deb12a8a001 (patch)
treeed3f53ed427cd2d2f8ab65ed89774f38c18216c4 /sys/dev/pci
parentd804c699c0c91251d3c417cfa24ca52cb57671d2 (diff)
Fix a possible NULL pointer dereference. Spotted by Tobias Ulmer; thanks!
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/drm/drmP.h3
1 files changed, 2 insertions, 1 deletions
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