Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1819657iob; Thu, 5 May 2022 08:45:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9X94F8Sf1FeOeiUAca4RDnvGYQ+fgm87qYAJHW+Xi4NO23pG3T8Wu1F3AY1s0TeWW8rAv X-Received: by 2002:a05:6402:3550:b0:427:c668:40d9 with SMTP id f16-20020a056402355000b00427c66840d9mr22611523edd.199.1651765519885; Thu, 05 May 2022 08:45:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651765519; cv=none; d=google.com; s=arc-20160816; b=Rgi8TWqaf+oLub9XcGt7zITMjzpNjkyRniSQ0oxhFj+y/2E368Lpk8YgfQhFtLxLmO PZ6xQGHs8xQNa5ACJovUYKY+CHCeJYdQX6SOmZq53gkHL7Lbl7/m8wBSyhx9b5KzHtwa cEiY56scQgSXOcdmQTxRSXMnexIxpGEjeTOMnBS57YN5xWq/+cq95xIvNYI9UIK6HAay hBsf+UjCQkhdBPqSRo1Dii5B3M/WplMzvFljIhva9sc5ScNRZyVunRqDVSEPqhYHhHho 8At9cBa0hayXx88/j+qALLvQEzO6KqpNzJivAnNabn3BgKv5sXFsUZNQtJ9KBShal8OD 2hbQ== 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=rsQrofRmebNzUygJ+t9N06gmvaFacKrdfxUeVm5jOeY=; b=jzQ/KxyNwyni2wHOFBxSKnwsZVVE9YfYD5pL2J2MOEEPcjOYAM53JV7zttLawRsPMb YRp4sF9mrNKiGPpgqt2alVbCjrf6lNqUJwR76e7+vUGKQeThr61StfvhAznHTfh5pTmC a7xapx44ffwvjW2WqrZHIZUKM+t6F5UjRXPI57D0F4lZr5OD09HEZCQ//Uq1ptwyDr8I 3sI2sM50FIAnL8xuTfpEskJDVsIVNfL3G7wwHbMpcUdZE1Gesg97lslpOtjFcBmLcfE7 jb4hsIg/zpddHOx2aTXfsl81EZCcBdi7FZM1O8bKT3nzqROuWdua+lhOBMC1QUMvIvxa 2q6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MJZ1TTMl; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a170906128600b006f4fc3e2c3esi1640590ejb.878.2022.05.05.08.44.56; Thu, 05 May 2022 08:45:19 -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=@linuxfoundation.org header.s=korg header.b=MJZ1TTMl; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359296AbiEDRoG (ORCPT + 99 others); Wed, 4 May 2022 13:44:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355966AbiEDRI5 (ORCPT ); Wed, 4 May 2022 13:08:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62652527C3; Wed, 4 May 2022 09:54:46 -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 391E361896; Wed, 4 May 2022 16:54:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859E7C385B9; Wed, 4 May 2022 16:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683285; bh=qoLkNOpHDZegcIXVQDcuYOHTdqmMBOW+KEJuAQFdY5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJZ1TTMlXyty+2KeAqNVyRQa4aCwPI76aOXSoQvEm8zkvINI1iEnks0wWqRc9kwmI /subMRICFTtGCiEBjxlEyUtEWh6GX8Cg+SQ7E0H//3LrFulmUw8E20hkEhfK6y/ZUb 2E4e5oG74HfTuxikGH1zoV4/HmO3G8txaR+qBqDc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Mark Brown , Sasha Levin Subject: [PATCH 5.15 128/177] ASoC: wm8731: Disable the regulator when probing fails Date: Wed, 4 May 2022 18:45:21 +0200 Message-Id: <20220504153104.570889166@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 From: Zheyu Ma [ Upstream commit 92ccbf17eeacf510cf1eed9c252d9332ca24f02d ] When the driver fails during probing, the driver should disable the regulator, not just handle it in wm8731_hw_init(). The following log reveals it: [ 17.812483] WARNING: CPU: 1 PID: 364 at drivers/regulator/core.c:2257 _regulator_put+0x3ec/0x4e0 [ 17.815958] RIP: 0010:_regulator_put+0x3ec/0x4e0 [ 17.824467] Call Trace: [ 17.824774] [ 17.825040] regulator_bulk_free+0x82/0xe0 [ 17.825514] devres_release_group+0x319/0x3d0 [ 17.825882] i2c_device_probe+0x766/0x940 [ 17.829198] i2c_register_driver+0xb5/0x130 Signed-off-by: Zheyu Ma Link: https://lore.kernel.org/r/20220405121038.4094051-1-zheyuma97@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm8731.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index dcee7b2bd3d7..859ebcec8383 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -602,7 +602,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731) ret = wm8731_reset(wm8731->regmap); if (ret < 0) { dev_err(dev, "Failed to issue reset: %d\n", ret); - goto err_regulator_enable; + goto err; } /* Clear POWEROFF, keep everything else disabled */ @@ -619,10 +619,7 @@ static int wm8731_hw_init(struct device *dev, struct wm8731_priv *wm8731) regcache_mark_dirty(wm8731->regmap); -err_regulator_enable: - /* Regulators will be enabled by bias management */ - regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); - +err: return ret; } @@ -766,21 +763,27 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, ret = PTR_ERR(wm8731->regmap); dev_err(&i2c->dev, "Failed to allocate register map: %d\n", ret); - return ret; + goto err_regulator_enable; } ret = wm8731_hw_init(&i2c->dev, wm8731); if (ret != 0) - return ret; + goto err_regulator_enable; ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8731, &wm8731_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); - return ret; + goto err_regulator_enable; } return 0; + +err_regulator_enable: + /* Regulators will be enabled by bias management */ + regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); + + return ret; } static int wm8731_i2c_remove(struct i2c_client *client) -- 2.35.1