From patchwork Thu Jun 15 10:53:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 693148 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 160BEEB64DB for ; Thu, 15 Jun 2023 10:54:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239248AbjFOKyF (ORCPT ); Thu, 15 Jun 2023 06:54:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241757AbjFOKyE (ORCPT ); Thu, 15 Jun 2023 06:54:04 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 144611FE4; Thu, 15 Jun 2023 03:54:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1686826443; x=1718362443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=roTYgP3DrDdWNlW0RbVAYG9eUbAOFUhPXtFqT0roqYE=; b=QGXBWTJN3NnAwnzlZmydxZ55aNem8kNme9gcb8Y+vihK/UNWvTdxiIfO zv0B5xEDBH/I/A/yG8VwRAqd5oczxBdMr94MMxmau3t6UdS2k56fwFyBI SeGW23E034zme+8bzGlTV2A67G5WSt1Paco834dFNB57sCbStvZgDo+Qo uBR4t/pmJTQTBI/vHhwu4k/6n1De+2k4Qc3h/Grzx1IAp74YdYz8kqU53 AIM9Bn8ZTIhAJbC73klVmYIZC1APDPqwUAEUwgCA0nFwBypbQwGBgYZUP FqubZQeE7mExKJ07yyIMy+qsgGp6bjnBckh5OmT9JiZDMItqT5ytejBfn w==; X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="218006732" 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:03 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex03.mchp-main.com (10.10.85.151) 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:53:56 -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:51 -0700 From: Claudiu Beznea To: , , , , , , , , CC: , , , Claudiu Beznea Subject: [PATCH 1/3] pinctrl: mcp23s08: check return value of devm_kasprintf() Date: Thu, 15 Jun 2023 13:53:31 +0300 Message-ID: <20230615105333.585304-2-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 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@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: 0f04a81784fe ("pinctrl: mcp23s08: Split to three parts: core, I²C, SPI") Signed-off-by: Claudiu Beznea --- drivers/pinctrl/pinctrl-mcp23s08_spi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c index 9ae10318f6f3..4013ffbfa282 100644 --- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c +++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c @@ -119,6 +119,9 @@ static int mcp23s08_spi_regmap_init(struct mcp23s08 *mcp, struct device *dev, return -EINVAL; } + if (!name || !mcp->chip.label) + return -ENOMEM; + copy = devm_kmemdup(dev, config, sizeof(*config), GFP_KERNEL); if (!copy) return -ENOMEM;