]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] v4l2-dev.c: Move video_put() after debug printk
authorEzequiel García <elezegarcia@gmail.com>
Thu, 26 Jul 2012 10:59:04 +0000 (07:59 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 31 Jul 2012 00:11:35 +0000 (21:11 -0300)
It is possible that video_put() releases video_device struct,
provoking a panic when debug printk wants to get video_device node name.

Signed-off-by: Ezequiel Garcia <elezegarcia@gmail.com>
Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/v4l2-dev.c

index 625248585c858a423a3b3565feb1d4b3de02b0ad..07aeafca9eaabfd0f23117168945f0d1e603533a 100644 (file)
@@ -478,12 +478,12 @@ static int v4l2_open(struct inode *inode, struct file *filp)
        }
 
 err:
-       /* decrease the refcount in case of an error */
-       if (ret)
-               video_put(vdev);
        if (vdev->debug)
                printk(KERN_DEBUG "%s: open (%d)\n",
                        video_device_node_name(vdev), ret);
+       /* decrease the refcount in case of an error */
+       if (ret)
+               video_put(vdev);
        return ret;
 }
 
@@ -500,12 +500,12 @@ static int v4l2_release(struct inode *inode, struct file *filp)
                if (test_bit(V4L2_FL_LOCK_ALL_FOPS, &vdev->flags))
                        mutex_unlock(vdev->lock);
        }
-       /* decrease the refcount unconditionally since the release()
-          return value is ignored. */
-       video_put(vdev);
        if (vdev->debug)
                printk(KERN_DEBUG "%s: release\n",
                        video_device_node_name(vdev));
+       /* decrease the refcount unconditionally since the release()
+          return value is ignored. */
+       video_put(vdev);
        return ret;
 }