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 47BBBCDB47E for ; Wed, 18 Oct 2023 14:14:14 +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 8D455829; Wed, 18 Oct 2023 16:13:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8D455829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1697638452; bh=4yP0p8uAZYIj+91adeBpZ1NU/8m+W/B803ERiNsO9yo=; 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=Teop9ESk4U2PKFTUKeIcXOiU5vRkFW4HCTMynjVe3KQ2+yHOsV0YN2L/qlnpWndjl N0bW7iPwlktbWAGr/to6BCxzfSHxwjbqnPcN6fbFdt6/ovfoUOolKLpzhxqBQPN535 /8mX/m6IfFSZpqR0Zsy9HpwlZrwTOFKbYApgfOM4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3C3A5F8057A; Wed, 18 Oct 2023 16:12:21 +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 D1983F8057A; Wed, 18 Oct 2023 16:12:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A5B0F8055C; Wed, 18 Oct 2023 16:12:16 +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) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8AA2EF8019B for ; Wed, 18 Oct 2023 16:12:10 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8AA2EF8019B 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=D8bLXYFx Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id C236C617F7; Wed, 18 Oct 2023 14:12:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7E46C433C8; Wed, 18 Oct 2023 14:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697638327; bh=4yP0p8uAZYIj+91adeBpZ1NU/8m+W/B803ERiNsO9yo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8bLXYFxbOTRjcR7RhsTPcurbe9fNLeJnkzuYZ0NfR7q3L0mzxzZuiC6dMYLZcRe8 gwY+vb5SRHBadWq9oPJIS96DuVRd2bY/pKLmvOtYah+QozHWDRfn14KstUApfa+2Rd Y4ujpdxmZ6c1+Tlna6k+WdXF13oT6HQnysw/wSvE+Kx7PcTrJqFLN5ARMy4GdxD6Wl IkoUYlNajmnvKaoz2tjmBH9RIedOkwCjZqTGOYnxvEsMAfJyG9elmQgVpYOFiVP2mj vV8jZ43H5zVJykVbQZDG4GdyR7vOWeK2V5PrqF+P+pQwfyrLAaHKwtnBvo8IpdI3J+ 2hU9kMHAsfiwA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kuninori Morimoto , kernel test robot , Dan Carpenter , Mark Brown , Sasha Levin , lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com, herve.codina@bootlin.com, christophe.leroy@csgroup.eu, astrid.rost@axis.com, aidanmacdonald.0x0@gmail.com, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 6.5 04/31] ASoC: simple-card: fixup asoc_simple_probe() error handling Date: Wed, 18 Oct 2023 10:11:21 -0400 Message-Id: <20231018141151.1334501-4-sashal@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231018141151.1334501-1-sashal@kernel.org> References: <20231018141151.1334501-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.5.7 Content-Transfer-Encoding: 8bit Message-ID-Hash: KGN7KLM6T4IEY2OA5KWDSVHX52ODGCKS X-Message-ID-Hash: KGN7KLM6T4IEY2OA5KWDSVHX52ODGCKS 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: Kuninori Morimoto [ Upstream commit 41bae58df411f9accf01ea660730649b2fab1dab ] asoc_simple_probe() is used for both "DT probe" (A) and "platform probe" (B). It uses "goto err" when error case, but it is not needed for "platform probe" case (B). Thus it is using "return" directly there. static int asoc_simple_probe(...) { ^ if (...) { | ... (A) if (ret < 0) | goto err; v } else { ^ ... | if (ret < 0) (B) return -Exxx; v } ... ^ if (ret < 0) (C) goto err; v ... err: (D) simple_util_clean_reference(card); return ret; } Both case are using (C) part, and it calls (D) when err case. But (D) will do nothing for (B) case. Because of these behavior, current code itself is not wrong, but is confusable, and more, static analyzing tool will warning on (B) part (should use goto err). To avoid static analyzing tool warning, this patch uses "goto err" on (B) part. Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Kuninori Morimoto Link: https://lore.kernel.org/r/87o7hy7mlh.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/simple-card.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 0745bf6a09aa0..5005d3c9c659a 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -701,10 +701,12 @@ static int asoc_simple_probe(struct platform_device *pdev) struct snd_soc_dai_link *dai_link = priv->dai_link; struct simple_dai_props *dai_props = priv->dai_props; + ret = -EINVAL; + cinfo = dev->platform_data; if (!cinfo) { dev_err(dev, "no info for asoc-simple-card\n"); - return -EINVAL; + goto err; } if (!cinfo->name || @@ -713,7 +715,7 @@ static int asoc_simple_probe(struct platform_device *pdev) !cinfo->platform || !cinfo->cpu_dai.name) { dev_err(dev, "insufficient asoc_simple_card_info settings\n"); - return -EINVAL; + goto err; } cpus = dai_link->cpus; -- 2.40.1