]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
drm: restore open_count if drm_setup fails
authorIlija Hadzic <ilijahadzic@gmail.com>
Mon, 29 Oct 2012 17:35:00 +0000 (17:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 17 Nov 2012 21:16:12 +0000 (13:16 -0800)
commit 0f1cb1bd94a9c967cd4ad3de51cfdabe61eb5dcc upstream.

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>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/drm_fops.c

index 123de28f94ef0613441b6656e9be9f309577c387..b90abff193415f949c87ef0befcd629490175782 100644 (file)
@@ -139,8 +139,11 @@ int drm_open(struct inode *inode, struct file *filp)
        retcode = drm_open_helper(inode, filp, dev);
        if (!retcode) {
                atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
-               if (!dev->open_count++)
+               if (!dev->open_count++) {
                        retcode = drm_setup(dev);
+                       if (retcode)
+                               dev->open_count--;
+               }
        }
        if (!retcode) {
                mutex_lock(&dev->struct_mutex);