Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2056484rdb; Tue, 3 Oct 2023 08:59:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHoe+iyxzEenffy5bLm4pFRGV7s5sDwgF2xA1JLW2GS712R0qvjfIcjaS7QWwH1gRU2fGYo X-Received: by 2002:a05:6a20:96d3:b0:14d:abc:73dc with SMTP id hq19-20020a056a2096d300b0014d0abc73dcmr11363714pzc.32.1696348775787; Tue, 03 Oct 2023 08:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696348775; cv=none; d=google.com; s=arc-20160816; b=gEAxqSjnWv4mncGk2qiQKhxd5Xm5qdnXYHqo6GuelBnF3WAsj/mXn9QSlt8e6IO/X7 JAYlb0noMzGjLHW3ovEEECvqTeuAElND10ERrgy2Nko78xwIEKYkSc97RV2NLCdoGqYt cFuggihB+7YprxSQ7GTt/ovjBxVHES/wuPwsyzNT83MN+ytv2uKbPGn8SFdNC/1EG24i d2bN7P65fW96xfirbZRZLLMwpVwDjJr8cjq/pxFpT/N0xhx8at+Ek/AwdwMG7LlxxVLA 3Gt94HVVwP8Y+J37OwfGwKGBdVfe5KoUzuQkNIQj482vw85pl7sFzNgLuaVU2XTe9AtX 2vgg== 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:date:subject:cc:to:from :dkim-signature; bh=J3LgqUc0oC3qi06VZNYBYeIn+4p6m0TgpCuhplardck=; fh=A7ESGAPW6WV+DCQVqmR+9L9s97lYo7gbF/gPHfKJi14=; b=bgBEZwtP7Uf7hETlXVNDl0anrT/ongSA/DXYrVaW1tusaTj4oCW0nKxP9lJwCbTh2y 5adJ8hf3bFKb9xJN7go1Rk9e0inyeo3FjM21bNuVJDQofil0RDsNz7mPOqDQxjgV6FfC mDwNjNHEdmxc44ZiENwAh0HJRk45XZ+wbE6OjVdXmkHd24FXa5Kx4MDlydC9GI3Z65Es kbYc/hhoFm2jTGBv/XGPYJGuWAcLE3dMzVZcA+nEHwNsL5BUx5c0BQAaf7VytoeZbOBD ANy8XCf7ArQ4FRlOlrLiq1MwLz84iApq06nN8YEybqRLL5FCD2loObAMe5GOYCKNZzgq AzYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fdZAqcOy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id f1-20020a170902ce8100b001bf1973eafcsi1876753plg.571.2023.10.03.08.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:59:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fdZAqcOy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 9D550816EF63; Tue, 3 Oct 2023 08:59:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239450AbjJCP6n (ORCPT + 99 others); Tue, 3 Oct 2023 11:58:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239326AbjJCP6g (ORCPT ); Tue, 3 Oct 2023 11:58:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F76A7; Tue, 3 Oct 2023 08:58:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8803C433CD; Tue, 3 Oct 2023 15:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696348711; bh=arWViVOFJ+xLCsEMqdnO3mqzkm5NiZn0WEmyp7nWPzo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fdZAqcOy0KP/1cr8Dv8F6l+6h8ksFQsBPP12k3onVO1ieCNudGaxOedU6ik3VEBBx 4Ckn4Wbd2Wdeq5/W9/Xp9Tmqaoqa5VJWlE4w8wWGO6fyvAuVl2u+xJsfIqT12CEILu Ps94+ShHf2JoB1r3E5EiHJ2sOWZjLYt3VuWg1YX59PWJUnB7P1binntFq+AAyd49Fb kXaqj2NFC1a+2/vrKRuJYYrn0cNz1OONGr8WiPnm8SXn5VtBg7WjlpAKUoPl3pfXSS PUkFepwIa/Mtv9jdJql495Fp6Geab+hH4YkrxCSg4htN5oxw7wesRjeuOgoBfryR/s wuewWIIxkdDGg== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qnhnG-00074t-0c; Tue, 03 Oct 2023 17:58:42 +0200 From: Johan Hovold To: Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 4/7] ASoC: codecs: wcd938x: fix regulator leaks on probe errors Date: Tue, 3 Oct 2023 17:55:55 +0200 Message-ID: <20231003155558.27079-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003155558.27079-1-johan+linaro@kernel.org> References: <20231003155558.27079-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:59:25 -0700 (PDT) Make sure to disable and free the regulators on probe errors and on driver unbind. Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver") Cc: stable@vger.kernel.org # 5.14 Cc: Srinivas Kandagatla Signed-off-by: Johan Hovold --- sound/soc/codecs/wcd938x.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index 7e0b07eeed77..679c627f7eaa 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -3325,8 +3325,10 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device return dev_err_probe(dev, ret, "Failed to get supplies\n"); ret = regulator_bulk_enable(WCD938X_MAX_SUPPLY, wcd938x->supplies); - if (ret) + if (ret) { + regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); return dev_err_probe(dev, ret, "Failed to enable supplies\n"); + } wcd938x_dt_parse_micbias_info(dev, wcd938x); @@ -3592,13 +3594,13 @@ static int wcd938x_probe(struct platform_device *pdev) ret = wcd938x_add_slave_components(wcd938x, dev, &match); if (ret) - return ret; + goto err_disable_regulators; wcd938x_reset(wcd938x); ret = component_master_add_with_match(dev, &wcd938x_comp_ops, match); if (ret) - return ret; + goto err_disable_regulators; pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_use_autosuspend(dev); @@ -3608,11 +3610,21 @@ static int wcd938x_probe(struct platform_device *pdev) pm_runtime_idle(dev); return 0; + +err_disable_regulators: + regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); + regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); + + return ret; } static void wcd938x_remove(struct platform_device *pdev) { + struct wcd938x_priv *wcd938x = dev_get_drvdata(&pdev->dev); + component_master_del(&pdev->dev, &wcd938x_comp_ops); + regulator_bulk_disable(WCD938X_MAX_SUPPLY, wcd938x->supplies); + regulator_bulk_free(WCD938X_MAX_SUPPLY, wcd938x->supplies); } #if defined(CONFIG_OF) -- 2.41.0