diff options
author | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-04-12 13:57:57 +0000 |
---|---|---|
committer | Owain Ainsworth <oga@cvs.openbsd.org> | 2008-04-12 13:57:57 +0000 |
commit | 845099509bda04edae00d2ea742e42df4242e874 (patch) | |
tree | 9d6bd4ca8006d47cfd76e7a0193060614ba60254 /sys/dev/pci | |
parent | 56dfab7d84b243c6ba045f42d898bd29215413cb (diff) |
check the softc for null before we use it. Fixes a crash when drm is enabled
but no device attached when the X server tries to use it.
Tested by many.
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/drm/drm_drv.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c index d72c71adb74..fd8111f06f8 100644 --- a/sys/dev/pci/drm/drm_drv.c +++ b/sys/dev/pci/drm/drm_drv.c @@ -55,9 +55,6 @@ int drm_firstopen(drm_device_t *); int drm_lastclose(drm_device_t *); #ifdef __FreeBSD__ -#define DRIVER_SOFTC(unit) \ - ((drm_device_t *)devclass_get_softc(drm_devclass, unit)) - MODULE_VERSION(drm, 1); MODULE_DEPEND(drm, agp, 1, 1, 1); MODULE_DEPEND(drm, pci, 1, 1, 1); @@ -66,11 +63,6 @@ MODULE_DEPEND(drm, mem, 1, 1, 1); #endif #endif /* __FreeBSD__ */ -#if defined(__NetBSD__) || defined(__OpenBSD__) -#define DRIVER_SOFTC(unit) \ - ((drm_device_t *)device_lookup(&drm_cd, unit)) -#endif /* __NetBSD__ || __OpenBSD__ */ - static drm_ioctl_desc_t drm_ioctls[256] = { DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0), DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), @@ -696,6 +688,9 @@ drm_open(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p) int retcode = 0; dev = drm_get_device_from_kdev(kdev); + if (dev == NULL) + return (ENXIO); + #ifdef __OpenBSD__ dev->kdev = kdev; /* hack for now */ #endif @@ -847,6 +842,9 @@ drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags, int is_driver_ioctl = 0; drm_file_t *file_priv; + if (dev == NULL) + return ENODEV; + DRM_LOCK(); file_priv = drm_find_file_by_proc(dev, p); DRM_UNLOCK(); |