Skip to content

Commit 0f1cb1b

Browse files
ihadzicairlied
authored andcommitted
drm: restore open_count if drm_setup fails
If drm_setup (called at first open) fails, the whole open call has failed, so we should not keep the open_count incremented. Signed-off-by: Ilija Hadzic <ihadzic@research.bell-labs.com> Cc: stable@vger.kernel.org Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 3d70f8c commit 0f1cb1b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/gpu/drm/drm_fops.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ int drm_open(struct inode *inode, struct file *filp)
135135
retcode = drm_open_helper(inode, filp, dev);
136136
if (!retcode) {
137137
atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
138-
if (!dev->open_count++)
138+
if (!dev->open_count++) {
139139
retcode = drm_setup(dev);
140+
if (retcode)
141+
dev->open_count--;
142+
}
140143
}
141144
if (!retcode) {
142145
mutex_lock(&dev->struct_mutex);

0 commit comments

Comments
 (0)