From patchwork Wed Jun 14 12:15:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 692572 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 C5F6AEB64D9 for ; Wed, 14 Jun 2023 12:16:58 +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 05CB7820; Wed, 14 Jun 2023 14:16:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 05CB7820 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686745016; bh=P+MmFBvDwsbGKAJINRgeRSJGf75kuY7a6+YGCSbxmxY=; h=From:To:CC:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=Zid3aXVMGmuzaNW/D6lVG0HvhjX1AsmrWQNNt41Klo94mmIcYY3m2GtT8Yam7+G9K gAPz5PQ+C5sOgAB1s1d2nrr8j2NcZHRaU6V0hwo1GwOkY5LGWIlhyYeRaIf5SYR/Lw KAPDJBb2Ku8unV/ZILgw3HC5/jYT6azXu1l59oVM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id EB7C5F80552; Wed, 14 Jun 2023 14:15:42 +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 80F97F80149; Wed, 14 Jun 2023 14:15:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6FB24F80149; Wed, 14 Jun 2023 14:15:38 +0200 (CEST) Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id C4B2BF800BA for ; Wed, 14 Jun 2023 14:15:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C4B2BF800BA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=d+xPPclN DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1686744933; x=1718280933; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=P+MmFBvDwsbGKAJINRgeRSJGf75kuY7a6+YGCSbxmxY=; b=d+xPPclNepZK4ApnTO5Nh/cnYGGsWLhXJoMY9mGx0go0SDYovFjfdj2j m6S5TDN4yIxhbKd5+H+Vk21T0FCSr1gM6zn5sNyp2qfl8a7b+nNS1Ap6B +L9rus8lXWxiSew8a89aeQb3MGLzwLAJSxTKnXv0hwaOEKUuqRMI3OSZh VM57/j49SZ3J4LbfU00Vl8BCt5L4rBbfMU3BZ+obNRfP9aY50zuFPMiNY 08NFOWh74UhRRK5/727yjk8qZPaCc2RSHRYXg6m+x8r5/QXW1wXzDA8kE 2FqSnXc3AcCq4Fkyh5ql+iKODaV8g9nWhaZEf1W03UidWjz+ZhB+YB6fl A==; X-IronPort-AV: E=Sophos;i="6.00,242,1681196400"; d="scan'208";a="217804545" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Jun 2023 05:15:27 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 14 Jun 2023 05:15:27 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Wed, 14 Jun 2023 05:15:18 -0700 From: Claudiu Beznea To: , , , , , , , , , , , , CC: , , , , Claudiu Beznea Subject: [PATCH] ASoC: imx-audmix: check return value of devm_kasprintf() Date: Wed, 14 Jun 2023 15:15:09 +0300 Message-ID: <20230614121509.443926-1-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Message-ID-Hash: TBVRU56IO6ZI4ZA6ZQS5HKSGHC3XWQNR X-Message-ID-Hash: TBVRU56IO6ZI4ZA6ZQS5HKSGHC3XWQNR X-MailFrom: Claudiu.Beznea@microchip.com 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: devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script). Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver") Signed-off-by: Claudiu Beznea Acked-by: Shengjiu Wang --- Hi, This has been addressed using kmerr.cocci script proposed for update at [1]. Thank you, Claudiu Beznea [1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/ sound/soc/fsl/imx-audmix.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c index 2c57fe9d2d08..af06268ee57b 100644 --- a/sound/soc/fsl/imx-audmix.c +++ b/sound/soc/fsl/imx-audmix.c @@ -228,6 +228,8 @@ static int imx_audmix_probe(struct platform_device *pdev) dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s", fe_name_pref, args.np->full_name + 1); + if (!dai_name) + return -ENOMEM; dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name); @@ -236,6 +238,8 @@ static int imx_audmix_probe(struct platform_device *pdev) capture_dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s", dai_name, "CPU-Capture"); + if (!capture_dai_name) + return -ENOMEM; } priv->dai[i].cpus = &dlc[0]; @@ -263,6 +267,8 @@ static int imx_audmix_probe(struct platform_device *pdev) "AUDMIX-Playback-%d", i); be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL, "AUDMIX-Capture-%d", i); + if (!be_name || !be_pb || !be_cp) + return -ENOMEM; priv->dai[num_dai + i].cpus = &dlc[2]; priv->dai[num_dai + i].codecs = &dlc[3]; @@ -287,6 +293,9 @@ static int imx_audmix_probe(struct platform_device *pdev) priv->dapm_routes[i].source = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s", dai_name, "CPU-Playback"); + if (!priv->dapm_routes[i].source) + return -ENOMEM; + priv->dapm_routes[i].sink = be_pb; priv->dapm_routes[num_dai + i].source = be_pb; priv->dapm_routes[num_dai + i].sink = be_cp;