From patchwork Mon Jul 1 17:19:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 809996 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 85F11C3065A for ; Mon, 1 Jul 2024 17:20:08 +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 58CBEEB6; Mon, 1 Jul 2024 19:19:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 58CBEEB6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719854406; bh=dqfvYGwmOKhaiFHa1zCpcfeOXkzk+rPswzjvChsg7so=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=FE+h4La8TyPkfDSIcjcC/dj7mykB+/D+/k27CG1Kw/KfbNcYzIs7PAZwlgtsvbDLK 3m3r3okW6ARlYoA/85OetrV9LAGKPtsE0prPg0RWHfVZljCRxOg14ASvkGhREBoQ+P asCcnRn9XC1BtUjN1G3laDO1FX7hoSBr6jSRz0pQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id AFDEDF80589; Mon, 1 Jul 2024 19:19:35 +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 D2F44F8003A; Mon, 1 Jul 2024 19:19:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 51295F8028B; Mon, 1 Jul 2024 19:19:30 +0200 (CEST) Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 69F1EF8003A for ; Mon, 1 Jul 2024 19:19:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 69F1EF8003A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=PZQODAPw Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-364ff42999eso1193144f8f.3 for ; Mon, 01 Jul 2024 10:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719854361; x=1720459161; darn=alsa-project.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mFg/9L3rp+k4GtkOLXisVJYUePHQn+Z+ti8m2E06xN0=; b=PZQODAPwXqUwDT3NW0ey3LeRhQtDxZlY1nF2M3i7i7HoOrEYVYUvsCSX06Hub0TVdu 5DjMPLfv92UHenrnVNwkeptbWck4O+e4l9u9f8XYQItOuoOw+7LM3CGw4e45zBo2PZHx rPduVNqV3+Mpab4K9pMHEYnKpZYu96YiTGL09F4gbsK/yBn1ZrbMNx7C3XNJPEZsoicD tPt3UyAvVdh529SAg/IKwFzu+9bk4cI/TaMTd4W8PptGHmNzMVWl6wu/QWryeuemTgaR 5eDdDzfdA6NpTzmrPgVLXwpL5H8vN6charr3/qdeJ1BaTaEQ1W3tJC/+8ouz4gr3me9Z R8wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719854361; x=1720459161; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mFg/9L3rp+k4GtkOLXisVJYUePHQn+Z+ti8m2E06xN0=; b=VM0ler5X9BWMyzXwcdCgF1XRcJrk+xqp5Vb3FgIJbkJP8Q9Xn1sEBqhjjJAHpz0lwM I097d41XJH9uJJVlHkIjdXRayBUsxY3QAhYFxv2gvHlKGPUYQ3YHGRQ7YP7lB+HAfVcJ KZrF2HCBne23wHvrhYL2t6MG0vZM5ZyCp2LBRScE1iIQlhFgVNF2Bh8Dy0yCltUUh+3C V9KFGUvzyKcs7Y13LOHANmR3nvkeyhY9b5ieVhI31H9qhwmMBvPe9FPlc2onFXLI2ZPU L4Psbttu8JophYZn3NtbBsSMntTsUhyCNg9rkVJyszg4LRMGn8HUIS7kJZhQBLIIXS5Z UzuQ== X-Forwarded-Encrypted: i=1; AJvYcCVTePJE2tXtroMtptDcbyIA6yKBF73XCRLFI3ZyvlfUkyWQU2qpBbSzJQlDGb0CpLYG2lquXEgvo1d5OBbb3KtOY7DHSgATiz/nIWU= X-Gm-Message-State: AOJu0YyXQ20w6os0WPLjq8QN2V5ybCnBxg4lhO8Pboo3JgPG+ZX9Gar2 iNlnL3AgbntI5KrRETmaDAvJyXy5eic2HjM0J5Cq1hp3m/Ig/jf4xTmMwYWj/Nk= X-Google-Smtp-Source: AGHT+IHNR1ABH6PKyzk7JMg6Jn5J0bcvxQEYovEtPBYvIHQfTDJs3e3xsSp6WhWeIyvAPFDDKwmFyw== X-Received: by 2002:a5d:5f56:0:b0:367:437f:1785 with SMTP id ffacd0b85a97d-3677569950bmr5309302f8f.13.1719854360985; Mon, 01 Jul 2024 10:19:20 -0700 (PDT) Received: from krzk-bin.. ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a112e19sm10581137f8f.116.2024.07.01.10.19.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 10:19:20 -0700 (PDT) From: Krzysztof Kozlowski To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 1/2] ASoC: codecs: aw88395: Simplify with cleanup.h Date: Mon, 1 Jul 2024 19:19:16 +0200 Message-ID: <20240701171917.596173-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Message-ID-Hash: DZDYO2X4WTMBMWDJEYWPNXRKUADNQRE7 X-Message-ID-Hash: DZDYO2X4WTMBMWDJEYWPNXRKUADNQRE7 X-MailFrom: krzysztof.kozlowski@linaro.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.9 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: 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 --- sound/soc/codecs/aw88395/aw88395_lib.c | 51 +++++++++----------------- 1 file changed, 17 insertions(+), 34 deletions(-) diff --git a/sound/soc/codecs/aw88395/aw88395_lib.c b/sound/soc/codecs/aw88395/aw88395_lib.c index f25f6e0d4428..769ca32a5c8e 100644 --- a/sound/soc/codecs/aw88395/aw88395_lib.c +++ b/sound/soc/codecs/aw88395/aw88395_lib.c @@ -7,6 +7,7 @@ // Author: Bruce zhao // +#include #include #include #include "aw88395_lib.h" @@ -361,11 +362,11 @@ static int aw_dev_parse_raw_dsp_fw(unsigned char *data, unsigned int data_len, static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char *data, unsigned int data_len, struct aw_prof_desc *prof_desc) { - struct aw_bin *aw_bin; int ret; int i; - aw_bin = devm_kzalloc(aw_dev->dev, data_len + sizeof(struct aw_bin), GFP_KERNEL); + struct aw_bin *aw_bin __free(kfree) = kzalloc(data_len + sizeof(struct aw_bin), + GFP_KERNEL); if (!aw_bin) return -ENOMEM; @@ -375,7 +376,7 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char * ret = aw_parsing_bin_file(aw_dev, aw_bin); if (ret < 0) { dev_err(aw_dev->dev, "parse bin failed"); - goto parse_bin_failed; + return ret; } for (i = 0; i < aw_bin->all_bin_parse_num; i++) { @@ -387,10 +388,8 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char * data + aw_bin->header_info[i].valid_data_addr; break; case DATA_TYPE_DSP_REG: - if (aw_bin->header_info[i].valid_data_len & 0x01) { - ret = -EINVAL; - goto parse_bin_failed; - } + if (aw_bin->header_info[i].valid_data_len & 0x01) + return -EINVAL; swab16_array((u16 *)(data + aw_bin->header_info[i].valid_data_addr), aw_bin->header_info[i].valid_data_len >> 1); @@ -402,10 +401,8 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char * break; case DATA_TYPE_DSP_FW: case DATA_TYPE_SOC_APP: - if (aw_bin->header_info[i].valid_data_len & 0x01) { - ret = -EINVAL; - goto parse_bin_failed; - } + if (aw_bin->header_info[i].valid_data_len & 0x01) + return -EINVAL; swab16_array((u16 *)(data + aw_bin->header_info[i].valid_data_addr), aw_bin->header_info[i].valid_data_len >> 1); @@ -422,20 +419,17 @@ static int aw_dev_prof_parse_multi_bin(struct aw_device *aw_dev, unsigned char * } } prof_desc->prof_st = AW88395_PROFILE_OK; - ret = 0; -parse_bin_failed: - devm_kfree(aw_dev->dev, aw_bin); - return ret; + return 0; } static int aw_dev_parse_reg_bin_with_hdr(struct aw_device *aw_dev, uint8_t *data, uint32_t data_len, struct aw_prof_desc *prof_desc) { - struct aw_bin *aw_bin; int ret; - aw_bin = devm_kzalloc(aw_dev->dev, data_len + sizeof(*aw_bin), GFP_KERNEL); + struct aw_bin *aw_bin __free(kfree) = kzalloc(data_len + sizeof(*aw_bin), + GFP_KERNEL); if (!aw_bin) return -ENOMEM; @@ -445,14 +439,13 @@ static int aw_dev_parse_reg_bin_with_hdr(struct aw_device *aw_dev, ret = aw_parsing_bin_file(aw_dev, aw_bin); if (ret < 0) { dev_err(aw_dev->dev, "parse bin failed"); - goto parse_bin_failed; + return ret; } if ((aw_bin->all_bin_parse_num != 1) || (aw_bin->header_info[0].bin_data_type != DATA_TYPE_REGISTER)) { dev_err(aw_dev->dev, "bin num or type error"); - ret = -EINVAL; - goto parse_bin_failed; + return -EINVAL; } prof_desc->sec_desc[AW88395_DATA_TYPE_REG].data = @@ -461,15 +454,7 @@ static int aw_dev_parse_reg_bin_with_hdr(struct aw_device *aw_dev, aw_bin->header_info[0].valid_data_len; prof_desc->prof_st = AW88395_PROFILE_OK; - devm_kfree(aw_dev->dev, aw_bin); - aw_bin = NULL; - return 0; - -parse_bin_failed: - devm_kfree(aw_dev->dev, aw_bin); - aw_bin = NULL; - return ret; } static int aw_dev_parse_data_by_sec_type(struct aw_device *aw_dev, struct aw_cfg_hdr *cfg_hdr, @@ -678,21 +663,21 @@ static int aw_dev_cfg_get_multiple_valid_prof(struct aw_device *aw_dev, static int aw_dev_load_cfg_by_hdr(struct aw_device *aw_dev, struct aw_cfg_hdr *prof_hdr) { - struct aw_all_prof_info *all_prof_info; int ret; - all_prof_info = devm_kzalloc(aw_dev->dev, sizeof(struct aw_all_prof_info), GFP_KERNEL); + struct aw_all_prof_info *all_prof_info __free(kfree) = kzalloc(sizeof(*all_prof_info), + GFP_KERNEL); if (!all_prof_info) return -ENOMEM; ret = aw_dev_parse_dev_type(aw_dev, prof_hdr, all_prof_info); if (ret < 0) { - goto exit; + return ret; } else if (ret == AW88395_DEV_TYPE_NONE) { dev_dbg(aw_dev->dev, "get dev type num is 0, parse default dev"); ret = aw_dev_parse_dev_default_type(aw_dev, prof_hdr, all_prof_info); if (ret < 0) - goto exit; + return ret; } switch (aw_dev->prof_data_type) { @@ -710,8 +695,6 @@ static int aw_dev_load_cfg_by_hdr(struct aw_device *aw_dev, if (!ret) aw_dev->prof_info.prof_name_list = profile_name; -exit: - devm_kfree(aw_dev->dev, all_prof_info); return ret; } From patchwork Mon Jul 1 17:19:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 808861 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 BCADBC2BD09 for ; Mon, 1 Jul 2024 17:20:21 +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 B7454E9F; Mon, 1 Jul 2024 19:20:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B7454E9F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1719854419; bh=P21qd1OkbuiMrCjx3m8pH2sGiiMR71WkUYVgzpHXae8=; 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=PZwrNl/JQV+44Kh4ZQV6ARRa8Hi4kP7BH+XEfypdeaI0FaGUfM3fI78P5l0YUNAr4 z9XZ+ZqSHKt7lGYYEEA8dauf6PppybAXysK3YPYfLMYjL47y5OA1kxeVEs7XUJNyaC PtizqZLRAo76GO8uNRM9lw3Bc8u8Nmuw+H/7srXE= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C0F43F805DF; Mon, 1 Jul 2024 19:19:37 +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 563FEF805DF; Mon, 1 Jul 2024 19:19:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 362EAF80238; Mon, 1 Jul 2024 19:19:32 +0200 (CEST) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 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 14080F800E4 for ; Mon, 1 Jul 2024 19:19:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 14080F800E4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MEI4XdVt Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52cd717ec07so4160251e87.0 for ; Mon, 01 Jul 2024 10:19:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719854362; x=1720459162; darn=alsa-project.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yqja86UDKTFIc+qc3NF0+FAZFhHDXQ4XzxpjOTJHZXE=; b=MEI4XdVtGCluz/o2P9Xlerzkt74Td/MJ2AsGmJiRw2AZdFk0+cJcuS4V0IQ59NeX5/ i7c6l9SpEFJnINMC0FI/ZT0WolIpapGV/zQNdvQ/B8KBzu+/KcOE/BiDIdCBa5BBb+M/ n5QA7vAcWyK/PZgLOnGqn6VxNqefjkhDvqpHnt6yHo5TXV9XGmmMb295CeZCMWWMshzw BfuJTJ5k3pvtxG+clb3OOKpdkTcN1u7AUpjCDr2WIE8xXxVRxvH6WHnvHCa3Y6zs9DmJ yoG/6BAuCaRv1sjr1XcNmKUsHFCyYRLMW+/g7+j2G3AqojypaKVB0k7H2GCumhw0/s1L EQZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719854362; x=1720459162; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yqja86UDKTFIc+qc3NF0+FAZFhHDXQ4XzxpjOTJHZXE=; b=wTrwW6OX3Bha8YmNAwHgLhFyO16LP7i1RQm8qBPND+1U2IlQ245c3o7r6DalQ+JUcS JdRkdPgyw3Ks387CdcarvZeXCTWe4C7bGbpVslbwNNviMHI7t4K1KLIPhDJc35Wm07y6 bYMm6Rr5R7iI8bEFq8lscKWx8MBixntYaiZLWdWaY1NdQl6eRr9WJZ8HtQ8LDZxRu8MA YWZJPdB0X2kuapECOYDZXHFWioJTShhwpHYTqSj5oTyTNzqnfM2zz5zWOy8ny3M92J8B cO/9Bc4+j06RbcOp+r/3LOWvsk5IbpZJt3dj2w2A/SCfzL5N8jZJpe+b8P4gw2Cg4Us0 utaQ== X-Forwarded-Encrypted: i=1; AJvYcCVlhGgjTESljGOtC8Z4xFGTdbwsyhrkcak1afuvCtztPsPvH9POfgVyuo5uIdBwYYQAW4X1T70DG6ySGsnsVWFMtnb4Sg1X2QNl9QQ= X-Gm-Message-State: AOJu0YwIB2RMIzyGb3xuPcq/oQtuDHo1DuADWI7JAgn+aJJpRUmIeNX5 FgQbKnrzB2X5a3recQdE8rTAf7m/uBhGRxO8llkX7O/1DOlnrggc5OPk7RGWQDI= X-Google-Smtp-Source: AGHT+IEpcOPlfAXhpzDXXuXPLW36uadem/IXz8BjMrFDaiR4x1PqQz5+4iXhrAFqE4LAPZjFn+z0sg== X-Received: by 2002:a05:6512:1599:b0:52c:dc69:28f3 with SMTP id 2adb3069b0e04-52e8270fa7dmr4370670e87.52.1719854362487; Mon, 01 Jul 2024 10:19:22 -0700 (PDT) Received: from krzk-bin.. ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3675a112e19sm10581137f8f.116.2024.07.01.10.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 10:19:22 -0700 (PDT) From: Krzysztof Kozlowski To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , Banajit Goswami , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [PATCH 2/2] ASoC: qcom: topology: Simplify with cleanup.h Date: Mon, 1 Jul 2024 19:19:17 +0200 Message-ID: <20240701171917.596173-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701171917.596173-1-krzysztof.kozlowski@linaro.org> References: <20240701171917.596173-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Message-ID-Hash: DWK74J3IAVDQ6WCK3EOAIZGFTIW7WABU X-Message-ID-Hash: DWK74J3IAVDQ6WCK3EOAIZGFTIW7WABU X-MailFrom: krzysztof.kozlowski@linaro.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.9 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: 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 --- sound/soc/qcom/qdsp6/topology.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/qcom/qdsp6/topology.c b/sound/soc/qcom/qdsp6/topology.c index f4d62ea60baa..83319a928f29 100644 --- a/sound/soc/qcom/qdsp6/topology.c +++ b/sound/soc/qcom/qdsp6/topology.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2020, Linaro Limited +#include #include #include #include @@ -1288,18 +1289,19 @@ int audioreach_tplg_init(struct snd_soc_component *component) struct snd_soc_card *card = component->card; struct device *dev = component->dev; const struct firmware *fw; - char *tplg_fw_name; int ret; /* Inline with Qualcomm UCM configs and linux-firmware path */ - tplg_fw_name = kasprintf(GFP_KERNEL, "qcom/%s/%s-tplg.bin", card->driver_name, card->name); + char *tplg_fw_name __free(kfree) = kasprintf(GFP_KERNEL, "qcom/%s/%s-tplg.bin", + card->driver_name, + card->name); if (!tplg_fw_name) return -ENOMEM; ret = request_firmware(&fw, tplg_fw_name, dev); if (ret < 0) { dev_err(dev, "tplg firmware loading %s failed %d\n", tplg_fw_name, ret); - goto err; + return ret; } ret = snd_soc_tplg_component_load(component, &audioreach_tplg_ops, fw); @@ -1309,8 +1311,6 @@ int audioreach_tplg_init(struct snd_soc_component *component) } release_firmware(fw); -err: - kfree(tplg_fw_name); return ret; }