From patchwork Tue May 30 09:39:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13259610 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85ACFC77B73 for ; Tue, 30 May 2023 09:41:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230255AbjE3Jks (ORCPT ); Tue, 30 May 2023 05:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbjE3Jkj (ORCPT ); Tue, 30 May 2023 05:40:39 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4388C19C; Tue, 30 May 2023 02:40:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685439619; x=1716975619; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zaCpku09a8GcgYcESUClblE15AQp+FSilf+S/hwA1+k=; b=m63MsVKpRQkaRdOVATWkZrPT1iixUWDb0L682jzGv/OjtRbcTyHLiwbw umVRTWcIMhq1KDrRMowK4++H8imoHg+LqDQ803IqdRKEF2Yeclk2onODZ l/bss9CxsV0LLXBA6ICSFWg4P2PMD6BEZ8jJWQetf/wCq1LMMIGtkxoKX n/785UP5A4NOWDtOwmooLSOt2Jfhbd0f2pXioEE7ot11IJNo/kzyKnzGw B4HA/WH7i+BdPL11us0pmvbGrGOTr2cencGkr3UcHf2M1KxIfSVJ3EPiY c5Z+zSiQEeALX0HWWih5EigqYB4RZthB8nfXylyKX8ymt6ljpbPcpI6TN Q==; X-IronPort-AV: E=Sophos;i="6.00,203,1681196400"; d="scan'208";a="227558719" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 May 2023 02:40:18 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Tue, 30 May 2023 02:40:16 -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; Tue, 30 May 2023 02:40:11 -0700 From: Claudiu Beznea To: , , , , , , CC: , , , , , , , , , Claudiu Beznea Subject: [PATCH 8/8] clk: clocking-wizard: check return value of devm_kasprintf() Date: Tue, 30 May 2023 12:39:13 +0300 Message-ID: <20230530093913.1656095-9-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230530093913.1656095-1-claudiu.beznea@microchip.com> References: <20230530093913.1656095-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.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: 2046338dcbc6 ("ARM: mxs: Use soc bus infrastructure") Signed-off-by: Claudiu Beznea --- drivers/clk/xilinx/clk-xlnx-clock-wizard.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c index e83f104fad02..20e0e91552bc 100644 --- a/drivers/clk/xilinx/clk-xlnx-clock-wizard.c +++ b/drivers/clk/xilinx/clk-xlnx-clock-wizard.c @@ -648,6 +648,11 @@ static int clk_wzrd_probe(struct platform_device *pdev) } clkout_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s_out0", dev_name(&pdev->dev)); + if (!clkout_name) { + ret = -ENOMEM; + goto err_disable_clk; + } + if (nr_outputs == 1) { clk_wzrd->clkout[0] = clk_wzrd_register_divider (&pdev->dev, clkout_name,