From 339d7dbc077cb1de0501ede1373f3720a66ea644 Mon Sep 17 00:00:00 2001 From: remko Date: Wed, 16 Jan 2008 13:54:40 +0000 Subject: Dont accidentally remove a filesocket which is still in use. This gives problems when the DRM driver is loaded and the AIXGL extension is loaded , the AIXGL driver requests a drm_close and this will cause the radeon driver to fail while starting X windows. PR: kern/114688 Submitted by: vehemens Prodded by: Robert Noland Approved by: imp (mentor, a while ago already), anholt MFC After: 1 week --- sys/dev/drm/drm_drv.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'sys/dev/drm/drm_drv.c') diff --git a/sys/dev/drm/drm_drv.c b/sys/dev/drm/drm_drv.c index 0d23e96..71d9c75 100644 --- a/sys/dev/drm/drm_drv.c +++ b/sys/dev/drm/drm_drv.c @@ -711,6 +711,9 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p) return EINVAL; } + if (--priv->refs != 0) + goto done; + if (dev->driver.preclose != NULL) dev->driver.preclose(dev, filp); @@ -786,17 +789,17 @@ int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p) dev->buf_pgid = 0; #endif /* __NetBSD__ || __OpenBSD__ */ - if (--priv->refs == 0) { - if (dev->driver.postclose != NULL) - dev->driver.postclose(dev, priv); - TAILQ_REMOVE(&dev->files, priv, link); - free(priv, M_DRM); - } + if (dev->driver.postclose != NULL) + dev->driver.postclose(dev, priv); + + TAILQ_REMOVE(&dev->files, priv, link); + free(priv, M_DRM); /* ======================================================== * End inline drm_release */ + done: atomic_inc( &dev->counts[_DRM_STAT_CLOSES] ); #ifdef __FreeBSD__ device_unbusy(dev->device); -- cgit v1.1