drm_open doesn't lock before increasing dev->open_count
adam zeira
adamzeira at gmail.com
Sun Feb 6 09:24:52 PST 2011
is this a problem? before trying to submit a solution I wanted to make
sure with the experts
it seems open_count isn't locked and can cause problems
and if it is a problem, and needs to be solved, should locking be done
or is it better implemented with the (as I understand standard) kref?
http://lxr.linux.no/linux+v2.6.37/drivers/gpu/drm/drm_fops.c#L121
int drm_open(struct inode *inode, struct file *filp)
{
..<no lock>..
retcode = drm_open_helper(inode, filp, dev);
if (!retcode) {
atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
if (!dev->open_count++)
retcode = drm_setup(dev);
}
..
}
int drm_release(struct inode *inode, struct file *filp)
{
..<global lock>..
if (!--dev->open_count) {
if (atomic_read(&dev->ioctl_count)) {
DRM_ERROR("Device busy: %d\n",
atomic_read(&dev->ioctl_count));
retcode = -EBUSY;
} else
retcode = drm_lastclose(dev);
}
mutex_unlock(&drm_global_mutex);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/dri-devel/attachments/20110206/045755f8/attachment.htm>
More information about the dri-devel
mailing list