diff options
author | 2008-04-12 13:57:56 +0000 | |
---|---|---|
committer | 2008-04-12 13:57:56 +0000 | |
commit | 9a746e41e646a8049cd95c7f474397f7ee9a92c4 (patch) | |
tree | 0a834d47a859320952ce99b54fe9289a2f5c9484 | |
parent | Convert the list of agp memory over to a TAILQ instead of using a hand- (diff) | |
download | wireguard-openbsd-9a746e41e646a8049cd95c7f474397f7ee9a92c4.tar.xz wireguard-openbsd-9a746e41e646a8049cd95c7f474397f7ee9a92c4.zip |
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.
-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(); |