From patchwork Tue Sep 15 14:11:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 263837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1E2FC433E2 for ; Wed, 16 Sep 2020 00:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A71CA2078D for ; Wed, 16 Sep 2020 00:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600215245; bh=0uPjmulYsyNZ//rQ8QGW14anblW7jkrvTlwURNjbcyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=anVB9z2s9cd1kiXMO47sTA+BD4f0mvxnrlvX4YMHwg22cjRoFfG2ydC5zoCUZVoq1 KcgG80tTlLbi3rrIOhyaJcZjCAujLWkkIHzHy3417yTU2TB/dRybrRTIdniRSM90Mg 6mB0iFV5j69HOxB73WRVPgHWweyweMtCjcBlujfY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727160AbgIPAOC (ORCPT ); Tue, 15 Sep 2020 20:14:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:39892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726920AbgIOOYz (ORCPT ); Tue, 15 Sep 2020 10:24:55 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C096223E4; Tue, 15 Sep 2020 14:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179529; bh=0uPjmulYsyNZ//rQ8QGW14anblW7jkrvTlwURNjbcyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ni1b7CuCAT5aYLGeJlzJpPZ8BIjiIsEebwadxa09NCk/uYO6yo/vrBvb3qlxRAlmo DXsy1ce36JRB3EpNxsJoMYQyDli7flgjOUWjexZWtJJU0O6vzAtG7idkohqminm2wZ 4AbrVrAh1gPcldvUfEzqWfNAi5PumqZG21ZPu6OI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Angelo Compagnucci , Sasha Levin Subject: [PATCH 5.4 017/132] iio: adc: mcp3422: fix locking on error path Date: Tue, 15 Sep 2020 16:11:59 +0200 Message-Id: <20200915140644.935125552@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140644.037604909@linuxfoundation.org> References: <20200915140644.037604909@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Angelo Compagnucci [ Upstream commit a139ffa40f0c24b753838b8ef3dcf6ad10eb7854 ] Reading from the chip should be unlocked on error path else the lock could never being released. Fixes: 07914c84ba30 ("iio: adc: Add driver for Microchip MCP3422/3/4 high resolution ADC") Fixes: 3f1093d83d71 ("iio: adc: mcp3422: fix locking scope") Acked-by: Jonathan Cameron Signed-off-by: Angelo Compagnucci Link: https://lore.kernel.org/r/20200901093218.1500845-1-angelo.compagnucci@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/iio/adc/mcp3422.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index ea24d7c58b127..4d03b1f265d9c 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -144,8 +144,10 @@ static int mcp3422_read_channel(struct mcp3422 *adc, config &= ~MCP3422_PGA_MASK; config |= MCP3422_PGA_VALUE(adc->pga[req_channel]); ret = mcp3422_update_config(adc, config); - if (ret < 0) + if (ret < 0) { + mutex_unlock(&adc->lock); return ret; + } msleep(mcp3422_read_times[MCP3422_SAMPLE_RATE(adc->config)]); }