diff mbox

[V2,-next,media] media: i2c: lm3560: fix missing unlock on error in lm3560_get_ctrl().

Message ID 1386308607-6127-1-git-send-email-gshark.jeong@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Jeong Dec. 6, 2013, 5:43 a.m. UTC
Sorry I should have checked below things before sending the first patch.
Correct reference of reading values. (rval -> reg_val)
Add the missing unlock before return from function lm3560_get_ctrl()
to avoid deadlock. 
Thank you Dan Carpenter & Sakari.


Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com>
---
 drivers/media/i2c/lm3560.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Sakari Ailus Dec. 6, 2013, 10:38 p.m. UTC | #1
Hi Daniel,

Thanks for the update.

On Fri, Dec 06, 2013 at 02:43:27PM +0900, Daniel Jeong wrote:
> Sorry I should have checked below things before sending the first patch.

Applied to my tree with the above line removed, and subject changed slightly
to mention the other change. I hope that's ok for you. The subject becomes
"media: i2c: lm3560: fix missing unlock on error, fault handling".

I'll send a pull req over the week-end.
diff mbox

Patch

diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
index 3317a9a..ab5857d 100644
--- a/drivers/media/i2c/lm3560.c
+++ b/drivers/media/i2c/lm3560.c
@@ -172,28 +172,28 @@  static int lm3560_flash_brt_ctrl(struct lm3560_flash *flash,
 static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
 {
 	struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no);
+	int rval = -EINVAL;
 
 	mutex_lock(&flash->lock);
 
 	if (ctrl->id == V4L2_CID_FLASH_FAULT) {
-		int rval;
 		s32 fault = 0;
 		unsigned int reg_val;
 		rval = regmap_read(flash->regmap, REG_FLAG, &reg_val);
 		if (rval < 0)
-			return rval;
-		if (rval & FAULT_SHORT_CIRCUIT)
+			goto out;
+		if (reg_val & FAULT_SHORT_CIRCUIT)
 			fault |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
-		if (rval & FAULT_OVERTEMP)
+		if (reg_val & FAULT_OVERTEMP)
 			fault |= V4L2_FLASH_FAULT_OVER_TEMPERATURE;
-		if (rval & FAULT_TIMEOUT)
+		if (reg_val & FAULT_TIMEOUT)
 			fault |= V4L2_FLASH_FAULT_TIMEOUT;
 		ctrl->cur.val = fault;
-		return 0;
 	}
 
+out:
 	mutex_unlock(&flash->lock);
-	return -EINVAL;
+	return rval;
 }
 
 static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)