Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3302000pxk; Mon, 21 Sep 2020 10:05:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt1n+KpnbwztHSzk0taz5L0uFu2vzIZM46yWAeDIBlQP3WA5Y8707DtZt1LHSI4V1Zw7F3 X-Received: by 2002:aa7:d750:: with SMTP id a16mr654843eds.362.1600707926362; Mon, 21 Sep 2020 10:05:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707926; cv=none; d=google.com; s=arc-20160816; b=w8o3uW7EHrbVKnCfdgcW8IxNaSxLfxP6Ofkk05qUBT3Us+oB5vKxwGkfHe7bQteku6 vy8LaYcQ8LLU1uArkTKeSUfpP3FRqzqJAZTDxGN+1yZGCVVHp+eRHa/bAJ9YKtzgOq+K N+jzZUfQ9YoMhtC8Y+UaVTTyDCsvIxFRldUSH+rw8JK4yY1FgwYaYn2WRHZFRSBnOMNd GwxEWam2BQyMvyEBzRHaY9K1shhTXrCaEGSmWYiIuFbF0qx4UxHAFhSBOY9tORaBC9U1 +pQyH7C5Trn+pGHIxMCZdDN4a3iAg1OCIkeXJTheDAihsz568K2wp5rVIegiL6Hbe1f+ LWxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0DFwtU9x0K4KefhL7R6qT+VZ9GFtBJqsFovgHAQPfks=; b=h6DWv7UJLWU4Nz2ukSBofo1tTid35A/HXTrUBi4UPp2n7z2r2+cyKKJwS3RusT0lUD 8kQLAYup9bKQSjMV7vBXosT1qCsME9+5jXlFEtIQ6ligPu2+HZkV0UkAXy2K90Ya4BYc 8v1IyWt2Fdq8/S5lAoX1EgbnHvHH9KXXiHUcb6l/gT/u/CjiEM6rA3m6wnuMeHXJFDIB H0IvSaS0twSQcd+psADnPhO0dsde1JHqvX6PW7lQleU+J6yES01izQPUpyR53SY9w2Bw D3lktfkt8my1ZMaDO6ElWhKFI44FHHTQSJoHgjCMM7Qs43UZoWAAWdlLaACmQJOFTRbe iJew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R3oHo03v; 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 pw9si8470630ejb.624.2020.09.21.10.05.00; Mon, 21 Sep 2020 10:05:26 -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=R3oHo03v; 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 S1728557AbgIURBy (ORCPT + 99 others); Mon, 21 Sep 2020 13:01:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:40016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729189AbgIUQio (ORCPT ); Mon, 21 Sep 2020 12:38:44 -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 7586F239D0; Mon, 21 Sep 2020 16:38:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706323; bh=Pzs6qruw76I/AzHcSJLll67dnrGP7d8pxzuN+iy4L2Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R3oHo03v9s4WV23ybSIuGQD7Hx9etmIO3QLa201Bi1UGf9bARG4FABtkU1kXBBTVR LZ8/xfpamRfrAv5BqCWctfKfHa7fCd9dNYxdW9gadDiTSXsPQYCrA9/36pwGivByJt koD+IAkC3unxciOg753pzSRUL2Fwh3zbvexXhdg4= 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.14 24/94] iio: adc: mcp3422: fix locking on error path Date: Mon, 21 Sep 2020 18:27:11 +0200 Message-Id: <20200921162036.653636676@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162035.541285330@linuxfoundation.org> References: <20200921162035.541285330@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(-) --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c @@ -146,8 +146,10 @@ static int mcp3422_read_channel(struct m 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)]); }