Skip to contentSkip to conversation

stk1160: unlock on error path stk1160_set_alternate()

PATCH In review Dan Carpenter 3 participants 4 messages Aug 14, 2012 – Aug 15, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stk1160: unlock on error path stk1160_set_alternate()

There are some unlocks missing on error.

---
Applies on top of linux-next.

drivers/media/video/stk1160/stk1160-v4l.c +6 -4
index 360bdbe..1ad4ac1 100644
@@ -159,8 +159,9 @@ static bool stk1160_set_alternate(struct stk1160 *dev)
 
 static int stk1160_start_streaming(struct stk1160 *dev)
 {
-	int i, rc;
 	bool new_pkt_size;
+	int rc = 0;
+	int i;
 
 	/* Check device presence */
 	if (!dev->udev)
@@ -183,7 +184,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
 	if (!dev->isoc_ctl.num_bufs || new_pkt_size) {
 		rc = stk1160_alloc_isoc(dev);
 		if (rc < 0)
-			return rc;
+			goto out_unlock;
 	}
 
 	/* submit urbs and enables IRQ */
@@ -192,7 +193,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
 		if (rc) {
 			stk1160_err("cannot submit urb[%d] (%d)\n", i, rc);
 			stk1160_uninit_isoc(dev);
-			return rc;
+			goto out_unlock;
 		}
 	}
 
@@ -205,9 +206,10 @@ static int stk1160_start_streaming(struct stk1160 *dev)
 
 	stk1160_dbg("streaming started\n");
 
+out_unlock:
 	mutex_unlock(&dev->v4l_lock);
 
-	return 0;
+	return rc;
 }
 
 /* Must be called with v4l_lock hold */
#1 lore raw

Hi Dan,

Quoted 41 lines · Dan Carpenter

There are some unlocks missing on error.

---
Applies on top of linux-next.

drivers/media/video/stk1160/stk1160-v4l.c +4 -3
index 360bdbe..1ad4ac1 100644
@@ -159,8 +159,9 @@ static bool stk1160_set_alternate(struct stk1160 *dev)
 
 static int stk1160_start_streaming(struct stk1160 *dev)
 {
-       int i, rc;
        bool new_pkt_size;
+       int rc = 0;
+       int i;
 
        /* Check device presence */
        if (!dev->udev)
@@ -183,7 +184,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
        if (!dev->isoc_ctl.num_bufs || new_pkt_size) {
                rc = stk1160_alloc_isoc(dev);
                if (rc < 0)
-                       return rc;
+                       goto out_unlock;
        }
 
        /* submit urbs and enables IRQ */
@@ -192,7 +193,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
                if (rc) {
                        stk1160_err("cannot submit urb[%d] (%d)\n", i, rc);
                        stk1160_uninit_isoc(dev);
-                       return rc;
+                       goto out_unlock;
                }
        }
 
@@ -205,9 +206,10 @@ static int stk1160_start_streaming(struct stk1160 *dev)
 

drivers/media/video/stk1160/stk1160-v4l.c static int stk1160_start_streaming(struct stk1160 *dev) · line 215

Quoted 10 lines
drivers/media/video/stk1160/stk1160-v4l.c +2 -1
        stk1160_dbg("streaming started\n");
 
+out_unlock:
        mutex_unlock(&dev->v4l_lock);
 
-       return 0;
+       return rc;
 }
 
 /* Must be called with v4l_lock hold */

This and the other stk1160 patch looks good. I'll give them a test.

Thanks,
Ezequiel.

#2 lore raw

Em 14-08-2012 07:51, Ezequiel Garcia escreveu:

Quoted 49 lines

Hi Dan,

Quoted 46 lines · Dan Carpenter

There are some unlocks missing on error.

---
Applies on top of linux-next.

drivers/media/video/stk1160/stk1160-v4l.c +5 -3
index 360bdbe..1ad4ac1 100644
@@ -159,8 +159,9 @@ static bool stk1160_set_alternate(struct stk1160 *dev)
 
 static int stk1160_start_streaming(struct stk1160 *dev)
 {
-       int i, rc;
        bool new_pkt_size;
+       int rc = 0;
+       int i;
 
        /* Check device presence */
        if (!dev->udev)
@@ -183,7 +184,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
        if (!dev->isoc_ctl.num_bufs || new_pkt_size) {
                rc = stk1160_alloc_isoc(dev);
                if (rc < 0)
-                       return rc;
+                       goto out_unlock;
        }
 
        /* submit urbs and enables IRQ */
@@ -192,7 +193,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
                if (rc) {
                        stk1160_err("cannot submit urb[%d] (%d)\n", i, rc);
                        stk1160_uninit_isoc(dev);
-                       return rc;
+                       goto out_unlock;
                }
        }
 
@@ -205,9 +206,10 @@ static int stk1160_start_streaming(struct stk1160 *dev)
 
        stk1160_dbg("streaming started\n");
 
+out_unlock:
        mutex_unlock(&dev->v4l_lock);
 
Quoted 7 lines

drivers/media/video/stk1160/stk1160-v4l.c static int stk1160_start_streaming(struct stk1160 *dev) · line 215

Quoted 5 lines
drivers/media/video/stk1160/stk1160-v4l.c +1 -1
-       return 0;
+       return rc;
 }
 
 /* Must be called with v4l_lock hold */

This and the other stk1160 patch looks good. I'll give them a test.

Ok, I'll merge them both, with your ack.

Quoted 8 lines

Thanks,
Ezequiel.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 54 lines · Mauro Carvalho Chehab

Em 14-08-2012 07:51, Ezequiel Garcia escreveu:

Quoted 53 lines

Hi Dan,

Quoted 50 lines · Dan Carpenter

There are some unlocks missing on error.

---
Applies on top of linux-next.

drivers/media/video/stk1160/stk1160-v4l.c +6 -4
index 360bdbe..1ad4ac1 100644
@@ -159,8 +159,9 @@ static bool stk1160_set_alternate(struct stk1160 *dev)
 
 static int stk1160_start_streaming(struct stk1160 *dev)
 {
-       int i, rc;
        bool new_pkt_size;
+       int rc = 0;
+       int i;
 
        /* Check device presence */
        if (!dev->udev)
@@ -183,7 +184,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
        if (!dev->isoc_ctl.num_bufs || new_pkt_size) {
                rc = stk1160_alloc_isoc(dev);
                if (rc < 0)
-                       return rc;
+                       goto out_unlock;
        }
 
        /* submit urbs and enables IRQ */
@@ -192,7 +193,7 @@ static int stk1160_start_streaming(struct stk1160 *dev)
                if (rc) {
                        stk1160_err("cannot submit urb[%d] (%d)\n", i, rc);
                        stk1160_uninit_isoc(dev);
-                       return rc;
+                       goto out_unlock;
                }
        }
 
@@ -205,9 +206,10 @@ static int stk1160_start_streaming(struct stk1160 *dev)
 
        stk1160_dbg("streaming started\n");
 
+out_unlock:
        mutex_unlock(&dev->v4l_lock);
 
-       return 0;
+       return rc;
 }
 
Quoted 5 lines
Quoted 3 lines

drivers/media/video/stk1160/stk1160-v4l.c static int stk1160_start_streaming(struct stk1160 *dev) · line 215

Quoted 1 line
drivers/media/video/stk1160/stk1160-v4l.c +0 -0
 /* Must be called with v4l_lock hold */

This and the other stk1160 patch looks good. I'll give them a test.

Ok, I'll merge them both, with your ack.

That's fine.

Thanks,
Ezequiel.