Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: qcom: topology: Simplify with cleanup.h

Allocate memory, which is being freed at end of the scope, with
scoped/cleanup.h to reduce number of error paths and make code a bit
simpler.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://patch.msgid.link/20240701171917.596173-2-krzysztof.kozlowski@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Krzysztof Kozlowski and committed by
Mark Brown
a8915e2f d0f4ce8a

+5 -5
+5 -5
sound/soc/qcom/qdsp6/topology.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 // Copyright (c) 2020, Linaro Limited 3 3 4 + #include <linux/cleanup.h> 4 5 #include <sound/soc.h> 5 6 #include <sound/soc-dapm.h> 6 7 #include <sound/pcm.h> ··· 1289 1288 struct snd_soc_card *card = component->card; 1290 1289 struct device *dev = component->dev; 1291 1290 const struct firmware *fw; 1292 - char *tplg_fw_name; 1293 1291 int ret; 1294 1292 1295 1293 /* Inline with Qualcomm UCM configs and linux-firmware path */ 1296 - tplg_fw_name = kasprintf(GFP_KERNEL, "qcom/%s/%s-tplg.bin", card->driver_name, card->name); 1294 + char *tplg_fw_name __free(kfree) = kasprintf(GFP_KERNEL, "qcom/%s/%s-tplg.bin", 1295 + card->driver_name, 1296 + card->name); 1297 1297 if (!tplg_fw_name) 1298 1298 return -ENOMEM; 1299 1299 1300 1300 ret = request_firmware(&fw, tplg_fw_name, dev); 1301 1301 if (ret < 0) { 1302 1302 dev_err(dev, "tplg firmware loading %s failed %d\n", tplg_fw_name, ret); 1303 - goto err; 1303 + return ret; 1304 1304 } 1305 1305 1306 1306 ret = snd_soc_tplg_component_load(component, &audioreach_tplg_ops, fw); ··· 1311 1309 } 1312 1310 1313 1311 release_firmware(fw); 1314 - err: 1315 - kfree(tplg_fw_name); 1316 1312 1317 1313 return ret; 1318 1314 }