Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1868615rwb; Fri, 19 Aug 2022 10:43:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR4vI/WQQOGq7GnUP2Ox4fg381JpZrjtttpa4TaxF4RXvg0W2Wqe1YPnpl1hzrjHiUuSeUb9 X-Received: by 2002:a62:7bd6:0:b0:52d:4773:a3de with SMTP id w205-20020a627bd6000000b0052d4773a3demr8878281pfc.70.1660931039446; Fri, 19 Aug 2022 10:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660931039; cv=none; d=google.com; s=arc-20160816; b=PMKWnrgwF9KrGLNDVaedTuPwLBHpdWTEXoPsY7Gg++tZ/b+igtwgPAvqmPo3rti9Wg Z7KcvjQjLFj4TBszV74uxjUiTPETFr1ka1Ba/zQ4oL2w50y11rcr2qxqvyRFpJnOgoI3 iBnfzFNOnMrrfX6b0oWBIRCLaWHSWV4zi22z4H0NgJ0ztZyl9SyvXRsaZGcw94dCJMyQ Xz4eiQWcxxp+b1NkbWcxc41QI50zIBdnPJmDQ/D+lX0XCf2o0t1JLuNRgGPFyS78Yq/F Auzckd7nFxJMehizJiVOT8OKO6yZoWYpnfLWCSduyNEBSkBG7Fg7j3I0sndhsD0lg3N3 xX9g== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=4mPGf46N9EMOf2GmMrCjDz8CMHqsIKnwSL8AkzSNGPk=; b=IvEc8QwF1xfXwdqIiwLHrvUZ/BJrbhFnlJv9aSC1CslRnvlN5x17TDpDUVanpTijaE CcscL1u3FjUb8rKCxqvWMQ8WbbdRXo1nk1ULOKTo1PWCFe0jb3ZoOnKzWGjp7rVMkFCU 5UMJ+OVkfcQ0TI/Bi0gPp+sYG5vrWtmcx1WDUba3CfnmseP2+Tr8y4ravd8WSYvuqzax q1f0od+1O05ZcSBgOqx8/npXnecIAQ17CtJekis9M9lbxDeEKSqNW7CjO05EXgYiEvCV 9mkwGb9UZ1prohxQlENhO35OhN8ZJLiZPmsNjNssDYucvARKKfvYOpbRilSffzdxETDP DZdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JV4dbJxP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a637b4c000000b0041bbc1428besi649274pgn.877.2022.08.19.10.43.48; Fri, 19 Aug 2022 10:43:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JV4dbJxP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351808AbiHSRnN (ORCPT + 99 others); Fri, 19 Aug 2022 13:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354697AbiHSRml (ORCPT ); Fri, 19 Aug 2022 13:42:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99891133A4C; Fri, 19 Aug 2022 10:01:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0882F617C7; Fri, 19 Aug 2022 17:01:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D991C433B5; Fri, 19 Aug 2022 17:01:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660928509; bh=O5aPB64MRuuVf6y9WVzczPShckhm/cZfEc0YAuq8dDs=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=JV4dbJxPPXjyoF+4bqMneL9I1M423zOu4WvyE3jhYcifaOCedSxsBTgyaTYgTOxjy 3SPO5kfdFp6nMRtSPppgzAUvUJ807J8Hd8GO3T0u4QBEpJ2fL0GiW2h442+ehtoufK zp0wbi1+nfE5DmpGF7hIoF1XcvWBQK8FD2Ss2hSIZn7ot4fhNXqggtZ9BF+D+2UBFI RI06wl/iOljj/B6v5ds8pmXnbi4ke9l8hs51DlSisnxSFnCVZHSDS6ua0UTJeGQKpg Q7k9Vw8gtZ0XpH/RSt3lX14bwY5NCTXyF3m1z0krwx7ps2bbLwCiYxvS1bbPKDAUyS WZfZEtEaet5QA== Date: Fri, 19 Aug 2022 18:12:25 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Matti Vaittinen , Marcelo Schmitt , Lars-Peter Clausen , Michael Hennerich , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: ad7292: Prevent regulator double disable Message-ID: <20220819181225.3f6851d1@jic23-huawei> In-Reply-To: References: X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 19 Aug 2022 11:51:07 +0300 Matti Vaittinen wrote: > The ad7292 tries to add an devm_action for disabling a regulator at > device detach using devm_add_action_or_reset(). The > devm_add_action_or_reset() does call the release function should adding > action fail. The driver inspects the value returned by > devm_add_action_or_reset() and manually calls regulator_disable() if > adding the action has failed. This leads to double disable and messes > the enable count for regulator. > > Do not manually call disable if devm_add_action_or_reset() fails. > > Fixes: 506d2e317a0a ("iio: adc: Add driver support for AD7292") > Signed-off-by: Matti Vaittinen > Good spot. Applied to the fixes-togreg branch of iio.git and marked for stable. Jonathan > --- > > The bug was found during browsing the code. I don't have the hardware to > test this so reviewing and testing is highly appreciated. > --- > drivers/iio/adc/ad7292.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c > index 92c68d467c50..a2f9fda25ff3 100644 > --- a/drivers/iio/adc/ad7292.c > +++ b/drivers/iio/adc/ad7292.c > @@ -287,10 +287,8 @@ static int ad7292_probe(struct spi_device *spi) > > ret = devm_add_action_or_reset(&spi->dev, > ad7292_regulator_disable, st); > - if (ret) { > - regulator_disable(st->reg); > + if (ret) > return ret; > - } > > ret = regulator_get_voltage(st->reg); > if (ret < 0)