summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>2025-12-03 17:12:39 +0100
committerMark Brown <broonie@kernel.org>2025-12-14 19:34:45 +0900
commitbafd5cf04b2822bf3c865add7262d86e22b9588e (patch)
treedefdc432d9db6f11a7b2ce1b756e92d12679e841
parent5a7e236925b417332a674a8488ef19da233a5764 (diff)
ASoC: amd: acp-sdw-sof: Fix confusing cleanup.h syntax
Initializing automatic __free variables to NULL without need (e.g. branches with different allocations), followed by actual allocation is in contrary to explicit coding rules guiding cleanup.h: "Given that the "__free(...) = NULL" pattern for variables defined at the top of the function poses this potential interdependency problem the recommendation is to always define and assign variables in one statement and not group variable definitions at the top of the function when __free() is used." Code does not have a bug, but is less readable and uses discouraged coding practice, so fix that by moving declaration to the place of assignment. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Link: https://patch.msgid.link/20251203-asoc-wrong-cleanup-h-continued-v1-2-5142be4874fb@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/amd/acp/acp-sdw-sof-mach.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sound/soc/amd/acp/acp-sdw-sof-mach.c b/sound/soc/amd/acp/acp-sdw-sof-mach.c
index 5677ae63fca9..da815b3f6389 100644
--- a/sound/soc/amd/acp/acp-sdw-sof-mach.c
+++ b/sound/soc/amd/acp/acp-sdw-sof-mach.c
@@ -270,8 +270,6 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
int sdw_be_num = 0, dmic_num = 0;
struct asoc_sdw_mc_private *ctx = snd_soc_card_get_drvdata(card);
struct snd_soc_acpi_mach_params *mach_params = &mach->mach_params;
- struct asoc_sdw_endpoint *sof_ends __free(kfree) = NULL;
- struct asoc_sdw_dailink *sof_dais __free(kfree) = NULL;
struct snd_soc_aux_dev *sof_aux;
struct snd_soc_codec_conf *codec_conf;
struct snd_soc_dai_link *dai_links;
@@ -289,12 +287,14 @@ static int sof_card_dai_links_create(struct snd_soc_card *card)
}
/* One per DAI link, worst case is a DAI link for every endpoint */
- sof_dais = kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL);
+ struct asoc_sdw_dailink *sof_dais __free(kfree) =
+ kcalloc(num_ends, sizeof(*sof_dais), GFP_KERNEL);
if (!sof_dais)
return -ENOMEM;
/* One per endpoint, ie. each DAI on each codec/amp */
- sof_ends = kcalloc(num_ends, sizeof(*sof_ends), GFP_KERNEL);
+ struct asoc_sdw_endpoint *sof_ends __free(kfree) =
+ kcalloc(num_ends, sizeof(*sof_ends), GFP_KERNEL);
if (!sof_ends)
return -ENOMEM;