diff options
| author | Jiri Slaby <jirislaby@gmail.com> | 2009-07-30 19:00:44 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-12 11:18:30 -0400 |
| commit | 00c1e2167e3163d2e193644b7d768f06d2a8c279 (patch) | |
| tree | 12ce3218cfea21b3127400aa741b54f1ee236e60 | |
| parent | b9ab3508efa57905ae037ddf48c97ea6ed74b799 (diff) | |
V4L/DVB (12373): hdpvr: fix lock imbalances
There are many lock imbalances in this driver. Fix all found.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
| -rw-r--r-- | drivers/media/video/hdpvr/hdpvr-core.c | 12 | ||||
| -rw-r--r-- | drivers/media/video/hdpvr/hdpvr-video.c | 6 |
2 files changed, 10 insertions, 8 deletions
diff --git a/drivers/media/video/hdpvr/hdpvr-core.c b/drivers/media/video/hdpvr/hdpvr-core.c index 188bd5aea258..1c9bc94c905c 100644 --- a/drivers/media/video/hdpvr/hdpvr-core.c +++ b/drivers/media/video/hdpvr/hdpvr-core.c | |||
| @@ -126,7 +126,7 @@ static int device_authorization(struct hdpvr_device *dev) | |||
| 126 | char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL); | 126 | char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL); |
| 127 | if (!print_buf) { | 127 | if (!print_buf) { |
| 128 | v4l2_err(&dev->v4l2_dev, "Out of memory\n"); | 128 | v4l2_err(&dev->v4l2_dev, "Out of memory\n"); |
| 129 | goto error; | 129 | return retval; |
| 130 | } | 130 | } |
| 131 | #endif | 131 | #endif |
| 132 | 132 | ||
| @@ -140,7 +140,7 @@ static int device_authorization(struct hdpvr_device *dev) | |||
| 140 | if (ret != 46) { | 140 | if (ret != 46) { |
| 141 | v4l2_err(&dev->v4l2_dev, | 141 | v4l2_err(&dev->v4l2_dev, |
| 142 | "unexpected answer of status request, len %d\n", ret); | 142 | "unexpected answer of status request, len %d\n", ret); |
| 143 | goto error; | 143 | goto unlock; |
| 144 | } | 144 | } |
| 145 | #ifdef HDPVR_DEBUG | 145 | #ifdef HDPVR_DEBUG |
| 146 | else { | 146 | else { |
| @@ -163,7 +163,7 @@ static int device_authorization(struct hdpvr_device *dev) | |||
| 163 | v4l2_err(&dev->v4l2_dev, "unknown firmware version 0x%x\n", | 163 | v4l2_err(&dev->v4l2_dev, "unknown firmware version 0x%x\n", |
| 164 | dev->usbc_buf[1]); | 164 | dev->usbc_buf[1]); |
| 165 | ret = -EINVAL; | 165 | ret = -EINVAL; |
| 166 | goto error; | 166 | goto unlock; |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | response = dev->usbc_buf+38; | 169 | response = dev->usbc_buf+38; |
| @@ -188,10 +188,10 @@ static int device_authorization(struct hdpvr_device *dev) | |||
| 188 | 10000); | 188 | 10000); |
| 189 | v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, | 189 | v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev, |
| 190 | "magic request returned %d\n", ret); | 190 | "magic request returned %d\n", ret); |
| 191 | mutex_unlock(&dev->usbc_mutex); | ||
| 192 | 191 | ||
| 193 | retval = ret != 8; | 192 | retval = ret != 8; |
| 194 | error: | 193 | unlock: |
| 194 | mutex_unlock(&dev->usbc_mutex); | ||
| 195 | return retval; | 195 | return retval; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| @@ -350,6 +350,7 @@ static int hdpvr_probe(struct usb_interface *interface, | |||
| 350 | 350 | ||
| 351 | mutex_lock(&dev->io_mutex); | 351 | mutex_lock(&dev->io_mutex); |
| 352 | if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) { | 352 | if (hdpvr_alloc_buffers(dev, NUM_BUFFERS)) { |
| 353 | mutex_unlock(&dev->io_mutex); | ||
| 353 | v4l2_err(&dev->v4l2_dev, | 354 | v4l2_err(&dev->v4l2_dev, |
| 354 | "allocating transfer buffers failed\n"); | 355 | "allocating transfer buffers failed\n"); |
| 355 | goto error; | 356 | goto error; |
| @@ -381,7 +382,6 @@ static int hdpvr_probe(struct usb_interface *interface, | |||
| 381 | 382 | ||
| 382 | error: | 383 | error: |
| 383 | if (dev) { | 384 | if (dev) { |
| 384 | mutex_unlock(&dev->io_mutex); | ||
| 385 | /* this frees allocated memory */ | 385 | /* this frees allocated memory */ |
| 386 | hdpvr_delete(dev); | 386 | hdpvr_delete(dev); |
| 387 | } | 387 | } |
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c index d678765cbba2..2eb9dc2ebe59 100644 --- a/drivers/media/video/hdpvr/hdpvr-video.c +++ b/drivers/media/video/hdpvr/hdpvr-video.c | |||
| @@ -375,6 +375,7 @@ static int hdpvr_open(struct file *file) | |||
| 375 | * in resumption */ | 375 | * in resumption */ |
| 376 | mutex_lock(&dev->io_mutex); | 376 | mutex_lock(&dev->io_mutex); |
| 377 | dev->open_count++; | 377 | dev->open_count++; |
| 378 | mutex_unlock(&dev->io_mutex); | ||
| 378 | 379 | ||
| 379 | fh->dev = dev; | 380 | fh->dev = dev; |
| 380 | 381 | ||
| @@ -383,7 +384,6 @@ static int hdpvr_open(struct file *file) | |||
| 383 | 384 | ||
| 384 | retval = 0; | 385 | retval = 0; |
| 385 | err: | 386 | err: |
| 386 | mutex_unlock(&dev->io_mutex); | ||
| 387 | return retval; | 387 | return retval; |
| 388 | } | 388 | } |
| 389 | 389 | ||
| @@ -519,8 +519,10 @@ static unsigned int hdpvr_poll(struct file *filp, poll_table *wait) | |||
| 519 | 519 | ||
| 520 | mutex_lock(&dev->io_mutex); | 520 | mutex_lock(&dev->io_mutex); |
| 521 | 521 | ||
| 522 | if (video_is_unregistered(dev->video_dev)) | 522 | if (video_is_unregistered(dev->video_dev)) { |
| 523 | mutex_unlock(&dev->io_mutex); | ||
| 523 | return -EIO; | 524 | return -EIO; |
| 525 | } | ||
| 524 | 526 | ||
| 525 | if (dev->status == STATUS_IDLE) { | 527 | if (dev->status == STATUS_IDLE) { |
| 526 | if (hdpvr_start_streaming(dev)) { | 528 | if (hdpvr_start_streaming(dev)) { |
