Details

[Home]

Issue of the Implementation # L0003

Brief

drivers/media/video/hdpvr/hdpvr-core.c(hdpvr-video.c): Mutex imbalances

Detailed Description

        In ./drivers/media/video/hdpvr/hdpvr-core.c in function device_authorization:         If after mutex lock (line 4) usb_control_msg returns ret!=46 we go to label error. In this case before exit from function mutex must be     unlocked.

01) static int device_authorization(struct hdpvr_device *dev)
02) {
03) ............
04)         mutex_lock(&dev->usbc_mutex);                                                    
05)        ret = usb_control_msg(dev->udev,
06)                               usb_rcvctrlpipe(dev->udev, 0),
07)                              rcv_request, 0x80 | request_type,
08)                              0x0400, 0x0003,
09)                              dev->usbc_buf, 46,10000);
10)             if (ret != 46) {
11)              v4l2_err(&dev->v4l2_dev,
12)                         "unexpected answer of status request, len %d
", 
ret);
13)                goto error;
14)        }
15) .................
16) error:
17)
18)        return retval;
19) }
 

Possible solutions

---
diff --git a/a/drivers/media/video/hdpvr/hdpvr-core.c 
b/b/drivers/media/video/hdpvr/hdpvr-core.c
index 188bd5a..1d03d1c 100644
--- a/a/drivers/media/video/hdpvr/hdpvr-core.c
+++ b/b/drivers/media/video/hdpvr/hdpvr-core.c
@@ -126,7 +126,7 @@ static int device_authorization(struct hdpvr_device *dev)
        char *print_buf = kzalloc(5*buf_size+1, GFP_KERNEL);
        if (!print_buf) {
                v4l2_err(&dev->v4l2_dev, "Out of memory
");
-               goto error;
+               return retval;
        }
 #endif

@@ -188,10 +188,10 @@ static int device_authorization(struct hdpvr_device 
*dev)
                              10000);
        v4l2_dbg(MSG_INFO, hdpvr_debug, &dev->v4l2_dev,
                 "magic request returned %d
", ret);
-       mutex_unlock(&dev->usbc_mutex);

        retval = ret != 8;
 error:
+       moutex_unlock(&dev->usbc_mutex);
        return retval;
 }

Component

linux-kernel 2.6.30

Accepted

http://lkml.org/lkml/2009/6/19/274
commit

Status

Fixed in kernel 2.6.32

[Home]