Skip to contentSkip to conversation

i2c: lm3560: missing unlocks on error in lm3560_set_ctrl()

PATCH In review Dan Carpenter 2 participants 2 messages Dec 16, 2013 – Jan 10, 2014

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

PATCH 1/1 i2c: lm3560: missing unlocks on error in lm3560_set_ctrl()

There are several error paths which don't unlock on error.

drivers/media/i2c/lm3560.c +10 -7
index ab5857d66f2d..fd96cfd6a9ec 100644
@@ -214,20 +214,22 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
 	case V4L2_CID_FLASH_STROBE_SOURCE:
 		rval = regmap_update_bits(flash->regmap,
 					  REG_CONFIG1, 0x04, (ctrl->val) << 2);
-		if (rval < 0)
-			goto err_out;
 		break;
 
 	case V4L2_CID_FLASH_STROBE:
-		if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH)
-			return -EBUSY;
+		if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) {
+			rval = -EBUSY;
+			goto err_unlock;
+		}
 		flash->led_mode = V4L2_FLASH_LED_MODE_FLASH;
 		rval = lm3560_mode_ctrl(flash);
 		break;
 
 	case V4L2_CID_FLASH_STROBE_STOP:
-		if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH)
-			return -EBUSY;
+		if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) {
+			rval = -EBUSY;
+			goto err_unlock;
+		}
 		flash->led_mode = V4L2_FLASH_LED_MODE_NONE;
 		rval = lm3560_mode_ctrl(flash);
 		break;
@@ -247,8 +249,9 @@ static int lm3560_set_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
 		break;
 	}
 
+err_unlock:
 	mutex_unlock(&flash->lock);
-err_out:
+
 	return rval;
 }
 
#1 lore raw

Hi Dan and Daniel,

Quoted 3 lines · Dan Carpenter

There are several error paths which don't unlock on error.

Thanks for the patch. However it seems this change has been already done by essentially similar patch (w/o the redundant rval check removal):

commit eed8c3eebce72fe4fc766f9a23e4324b04bd86cf

Author: Wei Yongjun <[email protected]>
Date:   Thu Nov 7 09:44:42 2013 -0300

[media] media: i2c: lm3560: fix missing unlock on error in lm3560_set_ctrl()

Add the missing unlock before return from function lm3560_set_ctrl() in the error handling case.

This patch is in Mauro's tree already (and possibly elsewhere).

Signature · 4 lines
Kind regards,

Sakari Ailus
e-mail: [email protected]	XMPP: [email protected]