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: 13279985 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 3400EEB64DB for ; Wed, 14 Jun 2023 12:15:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zOXEKeegO7xJnJyRCRAWvl1mp8HUNBuGTPq+f2Xovkw=; b=pAnyWJdSsf80oT RcjydMgQ8RJqVeSt4EM5Rv9Qf0a3i1lDyLE/tA2Y0WKVVvMNbZSbkTilKHoeejqgW9Q/T9ubQ7T73 g/SwznkvApOByeHuXqKPRQecLzA2891KMmlqjre0XokdT8UnZhTFkMkhOpowi3QkF4FcjhWf9WA/t EZRcfnD819ncwlCb47FDx0ReiGAWyLMHVCPejuqSZXSV/xRnhG0JXfrvaKCjNkOfut6917AFsCjeb ZOXH1A1+EBqkHKyJQyiUAIqoHDHVen/JHpCgk2posDsz2cyxAykmUrpErS7SRCdaKk9pWDzC66siy zDifzcwQTzTE/nROH8QA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9PPU-00BaxP-16; Wed, 14 Jun 2023 12:15:36 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9PPR-00BawL-0k for linux-arm-kernel@lists.infradead.org; Wed, 14 Jun 2023 12:15:35 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230614_051533_394199_60EE05A5 X-CRM114-Status: UNSURE ( 9.55 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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;