Skip to contentSkip to conversation

V4L/DVB: s5p-fimc: add unlock on error path

PATCH In review Dan Carpenter 2 participants 2 messages Oct 21, 2010 – Oct 22, 2010

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

PATCH 1/3 V4L/DVB: s5p-fimc: add unlock on error path

There was an unlock missing if kzalloc() failed.

drivers/media/video/s5p-fimc/fimc-core.c +7 -4
index 1802701..8335045 100644
@@ -1326,16 +1326,18 @@ static int fimc_m2m_open(struct file *file)
 	 * is already opened.
 	 */
 	if (fimc->vid_cap.refcnt > 0) {
-		mutex_unlock(&fimc->lock);
-		return -EBUSY;
+		err = -EBUSY;
+		goto err_unlock;
 	}
 
 	fimc->m2m.refcnt++;
 	set_bit(ST_OUTDMA_RUN, &fimc->state);
 
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
+	if (!ctx) {
+		err = -ENOMEM;
+		goto err_unlock;
+	}
 
 	file->private_data = ctx;
 	ctx->fimc_dev = fimc;
@@ -1355,6 +1357,7 @@ static int fimc_m2m_open(struct file *file)
 		kfree(ctx);
 	}
 
+err_unlock:
 	mutex_unlock(&fimc->lock);
 	return err;
 }
Acked-by on v1 1/3
#1 lore raw
Quoted 41 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Thursday, October 21, 2010 9:23 PM
To: Mauro Carvalho Chehab
Cc: Kyungmin Park; Sylwester Nawrocki; Marek Szyprowski; Pawel Osciak; [email protected]; [email protected]
Subject: [patch 1/3] V4L/DVB: s5p-fimc: add unlock on error path

There was an unlock missing if kzalloc() failed.

drivers/media/video/s5p-fimc/fimc-core.c +6 -4
index 1802701..8335045 100644
@@ -1326,16 +1326,18 @@ static int fimc_m2m_open(struct file *file)
 	 * is already opened.
 	 */
 	if (fimc->vid_cap.refcnt > 0) {
-		mutex_unlock(&fimc->lock);
-		return -EBUSY;
+		err = -EBUSY;
+		goto err_unlock;
 	}
 
 	fimc->m2m.refcnt++;
 	set_bit(ST_OUTDMA_RUN, &fimc->state);
 
 	ctx = kzalloc(sizeof *ctx, GFP_KERNEL);
-	if (!ctx)
-		return -ENOMEM;
+	if (!ctx) {
+		err = -ENOMEM;
+		goto err_unlock;
+	}
 
 	file->private_data = ctx;
 	ctx->fimc_dev = fimc;

drivers/media/video/s5p-fimc/fimc-core.c static int fimc_m2m_open(struct file *file) · line 1363

Quoted 7 lines
drivers/media/video/s5p-fimc/fimc-core.c +1 -0
@@ -1355,6 +1357,7 @@ static int fimc_m2m_open(struct file *file)
 		kfree(ctx);
 	}
 
+err_unlock:
 	mutex_unlock(&fimc->lock);
 	return err;
 }

Indeed it's my omission. Thanks.

--
Sylwester Nawrocki
Linux Platform Group
Samsung Poland R&D Center