From patchwork Fri Dec 6 05:43:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jeong X-Patchwork-Id: 3293101 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 11130C0D4A for ; Fri, 6 Dec 2013 05:44:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F86420444 for ; Fri, 6 Dec 2013 05:44:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3ECC120454 for ; Fri, 6 Dec 2013 05:44:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751243Ab3LFFnz (ORCPT ); Fri, 6 Dec 2013 00:43:55 -0500 Received: from mail-pb0-f52.google.com ([209.85.160.52]:36979 "EHLO mail-pb0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221Ab3LFFnv (ORCPT ); Fri, 6 Dec 2013 00:43:51 -0500 Received: by mail-pb0-f52.google.com with SMTP id uo5so426583pbc.25 for ; Thu, 05 Dec 2013 21:43:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IQk/e4Un8UpkblB3381y/gIpI2PBTh1YvhxqB6UB7r8=; b=lWPeHMPSkJL4NtB3hj4ue4yNu70Xrp+q+/0+p3Z0FRjA/MxP9hV7FGJPCMQP65HSm4 1dNJnIyr/Jg0tC45HFG1bzOBfXIuzUA+z3n5FE/BDUMIIQPWW678j1xgXoXvc1MbVM45 VvYYgzSk77GIqIiF+c1oUfhEmdhSX7uEntmGgwgbr6p76oQof73eAWdu07Rz227MhgAX 4aBTf6SJ9JUrVo9wK5FfPpU3V0Rd/GjfhKjCiWeR7Nr2t/BURwkgCYvV5QpxE4SkglEq RJIHOey4qMV0KHM0qwzUA+CgQHSoJNucO0Rj2YXyrbosf9b9V0wgy0zMJLRLAVwiB1cS stsg== X-Received: by 10.68.139.233 with SMTP id rb9mr1944492pbb.29.1386308631016; Thu, 05 Dec 2013 21:43:51 -0800 (PST) Received: from localhost.localdomain ([175.223.37.195]) by mx.google.com with ESMTPSA id uf2sm148901348pbc.28.2013.12.05.21.43.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 21:43:50 -0800 (PST) From: Daniel Jeong To: Mauro Carvalho Chehab , Sakari Ailus , Andy Shevchenko Cc: Hans Verkuil , Daniel Jeong , Dan Carpenter , Subject: [PATCH V2 -next] [media] media: i2c: lm3560: fix missing unlock on error in lm3560_get_ctrl(). Date: Fri, 6 Dec 2013 14:43:27 +0900 Message-Id: <1386308607-6127-1-git-send-email-gshark.jeong@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/media/i2c/lm3560.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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, ®_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)