Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3580978iob; Sat, 7 May 2022 08:51:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylGmELFYiGjNuE66ubh/Z+8Zv9DBDYxD2DEp9r14z5f/heQGfQJ2dOHifx89yd7TW5dDut X-Received: by 2002:a05:6a00:13a5:b0:50e:db7d:9df1 with SMTP id t37-20020a056a0013a500b0050edb7d9df1mr8680323pfg.54.1651938704207; Sat, 07 May 2022 08:51:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651938704; cv=none; d=google.com; s=arc-20160816; b=vuDNMZVSFB2txxVXI1V27YCX2jMMYUfImwuorj/LHr4GQ6f15jif8G3F5lMlQ+XoHD TqWrVcAjR9xBpjRiDFvAQpWw0uy0rMSsJH6PmjmZ0W87zH8Im1ybWElK/iDouQ2L7rcJ 3VLm6LRSMJ5F8xd0fZTOfCsb6OcDh8OAc9tGyaECO0n4SNh3T82/3ocYqozCO2hJP3G3 3DHiWRF6/qvyl1KDTh8iFHp4Iz8LouC0M2LqizB5tteRcThie9aRs1tY1x8oxS89ufw5 2HdSorIZ0c0R0HbJsaK8fpPKvE36rfELyCymiQWrr1Bv0Ma1b/7wW+rgpHsNY4kdayMP lNfw== 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=PNwaLLG+LEK0hjtHFbwWPsX/0AbyfMUvmBSXXzWMmmc=; b=PO8qla4GpKVTacpeYGTUJILMlUOchOkOvntyTzillIjW/8BiXTF8Vtl/eiQLQFoF8J 94e+3A+K04DYRunKoVFTO9JCLD9/hrjHge2AapbE8JmZIqVD9lWtHsOoBsdZWaod8Bkx g/Ti8kJbWJ6jXiQiFL/wnTO3I8V+U8WNrtTHOpzfvzqpABeF+IGUKiOJ00q9cgXgCxdQ RMLyUBNb3PORdjuArUAuRoZO9zuFReAkgDCIRUq+q2WYyv8Xd8lMBCrNztD4YRM4Sf8n qK9TjYeuLg4/q855GFZ0M60Oi7qrlqWbYoT1wyEat0slfJcyfC86bMPZa9R1OePTkCfq ATVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ttbYVYXS; 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 o4-20020a17090a4b4400b001da38e200d8si5889972pjl.0.2022.05.07.08.51.27; Sat, 07 May 2022 08:51:44 -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=ttbYVYXS; 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 S1356767AbiEDRJm (ORCPT + 99 others); Wed, 4 May 2022 13:09:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355582AbiEDRAQ (ORCPT ); Wed, 4 May 2022 13:00:16 -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 9C1D74B85F; Wed, 4 May 2022 09:51: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 ams.source.kernel.org (Postfix) with ESMTPS id 71005B827AC; Wed, 4 May 2022 16:51:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18E5BC385B0; Wed, 4 May 2022 16:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683108; bh=McgoWmkYHtizr58/vT6trUUdr52odY6eQseeCgR1VqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ttbYVYXSBZLudPzpCWa3cHsTbvQ+a6pDsbtL3AUZMAKVqpo2TUl05anYqVPbFNsp0 TAjAbrrhj7gd2zRx2m2XaJxxHfffUYmoloz2UuC4f3d+ygA3kQsL0OA1yRwDJc/hlR v9suZ4VgiZ34/ZRSkUyMOW5CMJ0A6YIePsTm8sOo= 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.10 100/129] ASoC: wm8731: Disable the regulator when probing fails Date: Wed, 4 May 2022 18:44:52 +0200 Message-Id: <20220504153028.878501207@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153021.299025455@linuxfoundation.org> References: <20220504153021.299025455@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 304bf725a613..24a009d73f1e 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