Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4650168iob; Sun, 8 May 2022 20:35:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFvVgQ/h1ezJRREcXI0XlX8PKq1hdbLNOh0FfhY4VlerWi170pKf4yRyMEibWE3CSpM/Zd X-Received: by 2002:a62:cf02:0:b0:50d:3e00:60c with SMTP id b2-20020a62cf02000000b0050d3e00060cmr13941290pfg.69.1652067327596; Sun, 08 May 2022 20:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652067327; cv=none; d=google.com; s=arc-20160816; b=Y2jdKkSnmoCpYAIPpFsf74FMpzPtXbcJi3x5snqhbQSU+22MuOL6Gej+fpJsDYDX0Z usbNaT+GGsO8OPL+ssESKWn39QCMY5pZyQr/R1NBe9H+5c1PCRPWW5gWZVRQPRHdQf63 /XP0uCMSLxppDoAw6JSbXCPLocod3OCFGpat859JGhgEAXcc7ak2AEgfM2GPceW0g5a1 GJethe2oUnw99FTSSdK5kUTFGvuDnqTZVQ1Lj4bxXiPUhnd450GUk5a1VPtO7gv+S/7K ZSJAGbLMMbJZR+EARCR6qAcidAKy+RkWonZ+PONV+LB+cea8wTBKc5NgPBz3P5Qks8TH WZog== 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=XUIb8pgdlP3DkNLgpCNdcxgDdQA9D967uHnpdpwuM3c=; b=HbwNBulyrUyHgIalecFXUnHLeKCCukRHyYvwZDgHmXSJPJjTOQ8zoqJwz6V/Je8bk7 rT/pGAinXXarvDsSUp/hjBbIYH2y3GWkGDP4+Nap9H5fSy7cAJkeeE+TIwtW6JQIACaD cCPj1WzHG/xwNDE3BHaH2RftONd0u9tjNJx+WMZsvpDHASGXgnEp2io06DgJBGpGBWdx /j39AlEbIVKmCWdrzaz9AYGmnCQH9rxO2Udq1itrGVIwoZwSvFjwWYzwYx2oQKBS6B0O 8n4fIIDQjueS93qWFm5WW+2FUyLLy+NzvzVcCpIVM6iBzxtvTCOGT/+iH2UmFrg4JXhV hWhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GH8gRQrk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j64-20020a638b43000000b003c619d7a434si12478658pge.164.2022.05.08.20.35.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 20:35:27 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GH8gRQrk; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 44966A7747; Sun, 8 May 2022 20:35:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239535AbiEDQzq (ORCPT + 99 others); Wed, 4 May 2022 12:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354187AbiEDQxz (ORCPT ); Wed, 4 May 2022 12:53:55 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BEC6483AB; Wed, 4 May 2022 09:49:12 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0819AB82554; Wed, 4 May 2022 16:49:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C91CC385A5; Wed, 4 May 2022 16:49:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651682949; bh=Yi/VZKwBWFltSoUl2IA96DoXBsbE40ytjiMP4EHVQC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GH8gRQrkRPpJq06oMh4mOaDba10eIQm+AILpnXvlOwwoleRvXsSvx8VfJJrugu8JZ +LRvHXJDMM0rOy4fvtY9ctjwHy74BqVj4dwDQQacwOzTqbWWZD4fjWIN4AEYYrFTrg rq7j8oQAv+AJ+tutawPcT2iELa9OzvJXHxpoqZrc= 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.4 68/84] ASoC: wm8731: Disable the regulator when probing fails Date: Wed, 4 May 2022 18:44:49 +0200 Message-Id: <20220504152932.744295450@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504152927.744120418@linuxfoundation.org> References: <20220504152927.744120418@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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 6fd1bef848ed..fa55d79b39b6 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -601,7 +601,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 */ @@ -618,10 +618,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; } @@ -765,21 +762,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