The patch number 12373 was added via Mauro Carvalho Chehab <mche...@redhat.com>
to http://linuxtv.org/hg/v4l-dvb master development tree.

Kernel patches in this development tree may be modified to be backward
compatible with older kernels. Compatibility modifications will be
removed before inclusion into the mainstream Kernel

If anyone has any objections, please let us know by sending a message to:
        Linux Media Mailing List <linux-me...@vger.kernel.org>

------

From: Jiri Slaby  <jirisl...@gmail.com>
hdpvr: fix lock imbalances


There are many lock imbalances in this driver. Fix all found.

Priority: normal

Signed-off-by: Jiri Slaby <jirisl...@gmail.com>
Signed-off-by: Douglas Schilling Landgraf <dougsl...@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mche...@redhat.com>


---

 linux/drivers/media/video/hdpvr/hdpvr-core.c  |   12 ++++++------
 linux/drivers/media/video/hdpvr/hdpvr-video.c |    6 ++++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diff -r 2ea40e33b6ff -r 3f2dffde2429 
linux/drivers/media/video/hdpvr/hdpvr-core.c
--- a/linux/drivers/media/video/hdpvr/hdpvr-core.c      Tue Jul 28 11:56:33 
2009 -0300
+++ b/linux/drivers/media/video/hdpvr/hdpvr-core.c      Thu Jul 30 20:00:44 
2009 -0300
@@ -126,7 +126,7 @@
        char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL);
        if (!print_buf) {
                v4l2_err(&dev->v4l2_dev, "Out of memory\n");
-               goto error;
+               return retval;
        }
 #endif
 
@@ -140,7 +140,7 @@
        if (ret != 46) {
                v4l2_err(&dev->v4l2_dev,
                         "unexpected answer of status request, len %d\n", ret);
-               goto error;
+               goto unlock;
        }
 #ifdef HDPVR_DEBUG
        else {
@@ -163,7 +163,7 @@
                v4l2_err(&dev->v4l2_dev, "unknown firmware version 0x%x\n",
                        dev->usbc_buf[1]);
                ret = -EINVAL;
-               goto error;
+               goto unlock;
        }
 
        response = dev->usbc_buf+38;
@@ -188,10 +188,10 @@
                              10000);
        v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
                 "magic request returned %d\n", ret);
-       mutex_unlock(&dev->usbc_mutex);
 
        retval = ret != 8;
-error:
+unlock:
+       mutex_unlock(&dev->usbc_mutex);
        return retval;
 }
 
@@ -350,6 +350,7 @@
 
        mutex_lock(&dev->io_mutex);
        if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) {
+               mutex_unlock(&dev->io_mutex);
                v4l2_err(&dev->v4l2_dev,
                         "allocating transfer buffers failed\n");
                goto error;
@@ -381,7 +382,6 @@
 
 error:
        if (dev) {
-               mutex_unlock(&dev->io_mutex);
                /* this frees allocated memory */
                hdpvr_delete(dev);
        }
diff -r 2ea40e33b6ff -r 3f2dffde2429 
linux/drivers/media/video/hdpvr/hdpvr-video.c
--- a/linux/drivers/media/video/hdpvr/hdpvr-video.c     Tue Jul 28 11:56:33 
2009 -0300
+++ b/linux/drivers/media/video/hdpvr/hdpvr-video.c     Thu Jul 30 20:00:44 
2009 -0300
@@ -375,6 +375,7 @@
         * in resumption */
        mutex_lock(&dev->io_mutex);
        dev->open_count++;
+       mutex_unlock(&dev->io_mutex);
 
        fh->dev = dev;
 
@@ -383,7 +384,6 @@
 
        retval = 0;
 err:
-       mutex_unlock(&dev->io_mutex);
        return retval;
 }
 
@@ -519,8 +519,10 @@
 
        mutex_lock(&dev->io_mutex);
 
-       if (video_is_unregistered(dev->video_dev))
+       if (video_is_unregistered(dev->video_dev)) {
+               mutex_unlock(&dev->io_mutex);
                return -EIO;
+       }
 
        if (dev->status == STATUS_IDLE) {
                if (hdpvr_start_streaming(dev)) {


---

Patch is available at: 
http://linuxtv.org/hg/v4l-dvb/rev/3f2dffde24291348806b6badf19f520efcdc9afb

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to