Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp23918pxk; Tue, 15 Sep 2020 16:41:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4YgW5II5XsuuWBIFpFG+6plEzHb1jHovP1T4XNPB8MUA1Dc4Q3BM8jZ4v7LEYLXocrhCG X-Received: by 2002:a17:906:692:: with SMTP id u18mr22369047ejb.43.1600213277550; Tue, 15 Sep 2020 16:41:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600213277; cv=none; d=google.com; s=arc-20160816; b=0alb8zFn+15r15XxG2DzSWBCNX9K1+gD8ePdlWHnBWs7impgZmw/8461OsiJuyU2WK G6mIbl665whVNkXuoqeYZr7RoK51p3ADEFBM9GXn3hnWuTZB32zdbUj9S8JOk3DtxASW T0c6xpfeeBThawVGnRQwfwGck0SIQTtIYV5lh7Z780YX/ZVToOlcj3NobcNzyhTgZMiJ 9bjZJAsVw5BPb8UdYHiKRpJ/XMaAonr5PrAbQcXBnMh4AeAx58QqoLwVIq1mGajMBSEc S/B9mTssNndnS8WxNGBCpNt31tGPIX/eLuk79QgfDhpJcs+kA3cJOs1/dS/HnN6SKZ1O GEeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jIMi0KdOtNq1GI35jfzFsnqSp581qe8Ggg2coH/3ZEw=; b=gHCLxSkcLSIG9K8Kp608eqPgBC17tKFlN3fyJqeCiO2IcciKEhVLOShPkUNNHIjUHq ckEyrBGbBcPYmPqGPubm0Alm5whyTKBt6I8zQykttguszTqzraN7TSxBqFjIZkkfcjLj kPOAocQypmIJf4xRbzabaeSK0NDUjhVED5czWWpv91nyD0d5eqY06G7x8XSuKGYuMUYb 6uPU7IYpsvFSmkaVv0+RvefPLsnPYyy9z+pVNj+Eyvpbzpwjajgq16+DRsZgr6t6+u3c QVtuP6Cr9lqxWUW3tVooE+4LuNQ3XMpb98jCMIWVIGS90pL4K0V2RcBVFY2YEYGy96tl qobg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XjsjSQRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si10597554edq.248.2020.09.15.16.40.55; Tue, 15 Sep 2020 16:41:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XjsjSQRf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727368AbgIOXkO (ORCPT + 99 others); Tue, 15 Sep 2020 19:40:14 -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 S1727109AbgIOOem (ORCPT ); Tue, 15 Sep 2020 10:34:42 -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 7C5AC22211; Tue, 15 Sep 2020 14:16:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179377; bh=g/ZbVp3gFIHqVMhtI6f2AuOJ8RFTxxibUkVrVntdm/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XjsjSQRf38b8lEwh5f8xb/oFKUJ4gxcKoJGKjhJCEoxovVIZdnilUMsT+m13LQxPJ 512eBhe9gmvF3aFrz1Td4vXC5NVS/4K200Y3uQQHruUHDXTa4tMh67B/2nLHQcIX4s kV7LBbFnHDeYdqVOLL11uJCwlyxxe9rA+j1Cv3F0= 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 4.19 09/78] iio: adc: mcp3422: fix locking on error path Date: Tue, 15 Sep 2020 16:12:34 +0200 Message-Id: <20200915140634.010489871@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 819f260115005..a5a687257c0b8 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -148,8 +148,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)]); } -- 2.25.1