[-next,media] media: i2c: lm3560: fix missing unlock error in lm3560_get_ctrl().
Commit Message
Add the missing unlock before return from function lm3560_get_ctrl()
to avoid deadlock. Thanks to Dan Carpenter.
Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com>
---
drivers/media/i2c/lm3560.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
Hi Daniel,
Thanks for the patch. (Dropping LKML; this isn't relevant there.)
On Thu, Nov 14, 2013 at 12:43:27PM +0900, Daniel Jeong wrote:
> Add the missing unlock before return from function lm3560_get_ctrl()
> to avoid deadlock. Thanks to Dan Carpenter.
>
> Signed-off-by: Daniel Jeong <gshark.jeong@gmail.com>
> ---
> drivers/media/i2c/lm3560.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
> index 3317a9a..5d6eef0 100644
> --- a/drivers/media/i2c/lm3560.c
> +++ b/drivers/media/i2c/lm3560.c
> @@ -172,16 +172,16 @@ 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, ®_val);
> if (rval < 0)
> - return rval;
> + goto out;
> if (rval & FAULT_SHORT_CIRCUIT)
> fault |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
> if (rval & FAULT_OVERTEMP)
> @@ -189,11 +189,11 @@ static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
> if (rval & 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)
The patch itself looks fine, but have you actually tested rading any fault
codes? Hint: regmap_read() returns zero on success. Yeah, I know... fault
codes can be a pain to test, and I, too, missed this on the first review
round.
I can take the patch to my tree and send a pull req if that's fine for you.
I case you also intend to write another, I'll take both at the same time.
@@ -172,16 +172,16 @@ 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, ®_val);
if (rval < 0)
- return rval;
+ goto out;
if (rval & FAULT_SHORT_CIRCUIT)
fault |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
if (rval & FAULT_OVERTEMP)
@@ -189,11 +189,11 @@ static int lm3560_get_ctrl(struct v4l2_ctrl *ctrl, enum lm3560_led_id led_no)
if (rval & 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)