From patchwork Tue Sep 15 14:11:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 309658 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 077C7C433E2 for ; Tue, 15 Sep 2020 23:35:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C122D206E6 for ; Tue, 15 Sep 2020 23:35:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600212955; bh=Q6PIUdt8ZgB7Y3N3ARJE1ShNYlta58o1j3AAS5uYWL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tT3gLFNeSGHFiiB/4oRKAQIqyhHnucJgPIDtD/5IYDYQEbcNaD2pC8/fWS2x3FF4j TT9A16IJFSb/s8zU5+BHe7u4EzFydStE/8cib6JnJ4ZHV6TX7FOp+y2grFny3xwN8V 6SDegrH20fNzRpe+J6V7XT+4TcnvBbw7R0fZqvkM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727418AbgIOXfy (ORCPT ); Tue, 15 Sep 2020 19:35:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:47674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727140AbgIOOfY (ORCPT ); Tue, 15 Sep 2020 10:35:24 -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 9D44E2226B; Tue, 15 Sep 2020 14:26:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179969; bh=Q6PIUdt8ZgB7Y3N3ARJE1ShNYlta58o1j3AAS5uYWL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DutJ4JIY7zRLhGrcEQ2NgBqZb1XuxWminWdeLeVpdDOR7fgPgnA23UQZH8uq0mYei do1ZiHxpOYcBfDmUP/LzhSwAJESIJ6FDpLyoGszeOm2T7H3YWh7c2pD2H4V+yB7wTr 0yebwxfSkIYgbSQKwNbNdFN0daWKV23bL2wONF8I= 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.8 027/177] iio: adc: mcp3422: fix locking on error path Date: Tue, 15 Sep 2020 16:11:38 +0200 Message-Id: <20200915140654.936022567@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140653.610388773@linuxfoundation.org> References: <20200915140653.610388773@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 d86c0b5d80a3d..c717981c8fb03 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -145,8 +145,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)]); }