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: 13281062 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 0F907EB64DB for ; Thu, 15 Jun 2023 10:54:23 +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=1iqpo5vRR0CoWY9qsOtBZ+0fmyvQHdOnLB7bozSO42g=; b=3bfIcJjaDOeBFT aYUbnpZGIunG7vR1As4QEaeqr9Et/KoDxFM4CFqL4162D4pPg3O1TBVU2rg8/egfTrOESfAZO5w9F UsryP7L1+5fcoQPQQRVVBWIGDeSpASWH3P2J+9CJ4ZIwsIOSRzXyW1cMI/C8LAOXhFx18SUEQnKuG kkw1SqacyEZXAojUhm5e+oNkFMJBuBTX/4XSqEbmobfCjdX5cax5r6aEq5DMVCuq34KKFPjBXxdFH 2Czts9rfbgBcYTdALNPxuS1/ogebQj80Er7uEdRFLSd7fmQtbGOiQBvftA6iWnCltwq0KwNylMoU6 BXSmhyr0lTPmcOg2U0vw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9kcA-00EcSx-2X; 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 1q9kc8-00EcJT-0H for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 10:54:05 +0000 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230615_035404_131489_377DB977 X-CRM114-Status: UNSURE ( 9.68 ) 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: 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;