From patchwork Thu Jun 15 10:53:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13281063 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 A14A3EB64DD for ; Thu, 15 Jun 2023 10:54:26 +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:References:In-Reply-To: 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: List-Owner; bh=WDIC7w7PspgSIq+yrsVHv+ms5tagKP1fHeKHZOa8gyQ=; b=P9+rvxq2f3Twdp hmkb3t8A7Qyt811gaZZ76Hmmqh9MoZcGGcrcvWhXO3h3EV/FC1XP7mHpIoLHSse9PXjr4/V4bvGWz jnTD6IdwPsZ1GhEkIB2FjoBaFfT9DJZChNUvk9zuV/Rs2O/F+LuYx2X0BqMNrmiXa6mcJRAv3maJL STe8fAD+xl4jdnw7ef1NXTxTZUQdUjTDQivsRYRlYciLpA24qyfLHmePX3c0VEbWZObNJnAfj3mGM tCuGWWREjm546Iv05tV0AgEm61GObcDWw1iwjlfLelcNUY+FVuWZORHlNpLxIzsDN/P7O4xzvoY2K ln0QiOqFWidIkIVK23Tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9kcA-00EcSS-10; Thu, 15 Jun 2023 10:54:06 +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 1q9kc6-00EcJT-0R for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 10:54:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1686826441; x=1718362441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3v+xI5WPh077/j0cQYGy7LYrHkohpui4PXNg4lHsRLY=; b=o7P8br4gAIyeK5YDjN6hpuU9ARopmlcu1LKKeUayl1DOCV5Ri6Vlz0Nz /JXYeD/V9dptzhq5rqgZ++mW4irLNpmi0GQKQyJS1hfv2ps7f5caE4VqK 2fz3aDb/6Up4zPKGmkSS1/o11j5CJZ6YyvmYLhARLEHS5gUE+FkEz4c1D 6DcG4CQmKlJA3OpUfrndeND3I2wQN0+/0+zpUwAlI0TKhsFuxRak7Fb8V UXAIgyur2ihUNKDw+udeDe6Xf6Z9nv2fUBR3ohBTGTFMUVZ9e+2CBP9SC tFQGcjQlidwP3G5xLV2NSXp0fWvbZsztBzYhAq3EC1LF104HmD1+ZSG3l g==; X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="218006713" 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; 15 Jun 2023 03:54:01 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Thu, 15 Jun 2023 03:54:01 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Thu, 15 Jun 2023 03:53:57 -0700 From: Claudiu Beznea To: , , , , , , , , CC: , , , Claudiu Beznea Subject: [PATCH 2/3] pinctrl: microchip-sgpio: check return value of devm_kasprintf() Date: Thu, 15 Jun 2023 13:53:32 +0300 Message-ID: <20230615105333.585304-3-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230615105333.585304-1-claudiu.beznea@microchip.com> References: <20230615105333.585304-1-claudiu.beznea@microchip.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230615_035402_179711_9CA714B7 X-CRM114-Status: UNSURE ( 9.27 ) 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: 7e5ea974e61c ("pinctrl: pinctrl-microchip-sgpio: Add pinctrl driver for Microsemi Serial GPIO") Signed-off-by: Claudiu Beznea Reviewed-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-microchip-sgpio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/pinctrl-microchip-sgpio.c b/drivers/pinctrl/pinctrl-microchip-sgpio.c index 4794602316e7..666d8b7cdbad 100644 --- a/drivers/pinctrl/pinctrl-microchip-sgpio.c +++ b/drivers/pinctrl/pinctrl-microchip-sgpio.c @@ -818,6 +818,9 @@ static int microchip_sgpio_register_bank(struct device *dev, pctl_desc->name = devm_kasprintf(dev, GFP_KERNEL, "%s-%sput", dev_name(dev), bank->is_input ? "in" : "out"); + if (!pctl_desc->name) + return -ENOMEM; + pctl_desc->pctlops = &sgpio_pctl_ops; pctl_desc->pmxops = &sgpio_pmx_ops; pctl_desc->confops = &sgpio_confops;