From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C300CEB64D7 for ; Fri, 16 Jun 2023 10:27:55 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E918B85D; Fri, 16 Jun 2023 12:27:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E918B85D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686911274; bh=NYh87GvRtAtdkGxE6uWmS8R93ymrl698MOMei6NKI38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HVtgteE2WWsP9T3kAqVPb2+U+TlaUrhfVPAq37oeSHwh5A5D9tRyINlADrSEu78ys 1IqWVSDaNAicIklfOsrXhAwQdwygsHytyxotUFzkj2FRWsI9tfAQWxldxPpoINns+G SfSO0ZX0SsrH/nkb6m24aAIA8Wi7JaxZ2I/BNcBo= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CFEFFF8059F; Fri, 16 Jun 2023 12:25:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 24D05F8059F; Fri, 16 Jun 2023 12:25:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7A27BF80149; Fri, 16 Jun 2023 12:25:42 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9B17CF80130 for ; Fri, 16 Jun 2023 12:25:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9B17CF80130 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=Vlid0DnO Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 68B3362B57; Fri, 16 Jun 2023 10:25:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F086C433C0; Fri, 16 Jun 2023 10:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686911138; bh=NYh87GvRtAtdkGxE6uWmS8R93ymrl698MOMei6NKI38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vlid0DnO9cec31MCNjgpBOkatqxn0v8I04vNpFlz5zhi1EseQXmm/+LLp1i88AWju klup646BA0vaLnwfo658Q6LWHFLCFWxPPEHs72J9jLGvgK19du+KzyaYd5L05fq/u0 e4DtEEwNxADwa7MGNWTrBwB7Zif+d0KOgrF3SSl0aO2iT3T5HTRc9sE7RJa/x3FkhF V9dYzkiVJG/puJ1vDAUt3drj6a2+2U6NUyDks4QcodsMkRGuugTrDmNadvJKFK3WcB VutUIeiJM4W59esKgM0h52hxDQtLwnxKeivuS9pvNVndBASFV3xzi+OQJty8d7YNB7 BBkcNJljomoDg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Krzysztof Kozlowski , Pierre-Louis Bossart , Vinod Koul , Sasha Levin , agross@kernel.org, andersson@kernel.org, yung-chuan.liao@linux.intel.com, linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 6.3 09/30] soundwire: qcom: add proper error paths in qcom_swrm_startup() Date: Fri, 16 Jun 2023 06:24:57 -0400 Message-Id: <20230616102521.673087-9-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230616102521.673087-1-sashal@kernel.org> References: <20230616102521.673087-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.3.8 Content-Transfer-Encoding: 8bit Message-ID-Hash: 6OPLQWBUM5X2TG62WHURIUF2L4WIC7JL X-Message-ID-Hash: 6OPLQWBUM5X2TG62WHURIUF2L4WIC7JL X-MailFrom: sashal@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Krzysztof Kozlowski [ Upstream commit 99e09b9c0ab43346c52f2787ca4e5c4b1798362e ] Reverse actions in qcom_swrm_startup() error paths to avoid leaking stream memory and keeping runtime PM unbalanced. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20230517163736.997553-1-krzysztof.kozlowski@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/soundwire/qcom.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c index 30575ed20947e..0dcdbd4e1ec3a 100644 --- a/drivers/soundwire/qcom.c +++ b/drivers/soundwire/qcom.c @@ -1098,8 +1098,10 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream, } sruntime = sdw_alloc_stream(dai->name); - if (!sruntime) - return -ENOMEM; + if (!sruntime) { + ret = -ENOMEM; + goto err_alloc; + } ctrl->sruntime[dai->id] = sruntime; @@ -1109,12 +1111,19 @@ static int qcom_swrm_startup(struct snd_pcm_substream *substream, if (ret < 0 && ret != -ENOTSUPP) { dev_err(dai->dev, "Failed to set sdw stream on %s\n", codec_dai->name); - sdw_release_stream(sruntime); - return ret; + goto err_set_stream; } } return 0; + +err_set_stream: + sdw_release_stream(sruntime); +err_alloc: + pm_runtime_mark_last_busy(ctrl->dev); + pm_runtime_put_autosuspend(ctrl->dev); + + return ret; } static void qcom_swrm_shutdown(struct snd_pcm_substream *substream, -- 2.39.2