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; 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; From patchwork Thu Jun 15 10:53:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 13281064 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 02A05EB64D9 for ; Thu, 15 Jun 2023 10:54:36 +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=D97wFkux+Efe91Q/DSYrvdtl0iu6diekoi5XRy/nPaQ=; b=2DCEVzxdaTsUpt yRk9zqr9Z62XrvtGALpVgbG82FWjrSZpmA90GMes0mkcVKxpyMT+4pk1q9OtIk6syP6YNOKB97YoM sIc4PhW1kPRxOLmLddDR3YQgoaMw/VQFjRBb5nBIP6finHOSeII4DWwTJ9Gw1q6QJRU+rIOGIwiBt x5hg9ponpYuRqdKiZ/Gu/fWoVDLyTISRkrssJeXyboQ4pXlpn8s/5V/vAq3IhWj7E2Raf7yh8Kvmj yUWdPKyFEtdgoMATsjcPqieFxiMCIctr2WmsrVmGW+EtNv3ZkwdLvwDwXzHLKrgyQbloxOP1MkjBK tmXs1/prxRu8OqCViYYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q9kcM-00Ecc5-26; Thu, 15 Jun 2023 10:54:18 +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 1q9kcK-00Eca3-03 for linux-arm-kernel@lists.infradead.org; Thu, 15 Jun 2023 10:54:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1686826455; x=1718362455; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fkwNJa0lrqgcBoAYQJldjJ8QWkitSk0hghnyQyG2tqs=; b=hT9Nt/YdvKF7OJU2kBX7ebjgrYQwFzQ0wi1fgS3SgxQxMwQ/yEW7wwwD Etyc26BUl87d/CTiLDR4yZ8QuRV4nbiCCHlsqLuVRR92Px0Of3+QQfrGx hdL4vTbJ12QOqQUEvMtJ/e9Dmm4l2vB4+0o7lvfwaBP4sB7iagqV+Ry9f Bqm8UovqRIhRYWmjuMU2EvZQg7lTJCzg5zqb0Lcd9M3X0rcLw8txbxG7Z jYf4M1UfTsx3+slTNX8ZUp5KitcIbClV6Jpe1tPtPjSDrQm0errGO1qCx wp3VJbQImV8olCph7USS4eP/be9i927bAUkFXgj47+Oorok2DdT4OYj+6 g==; X-IronPort-AV: E=Sophos;i="6.00,244,1681196400"; d="scan'208";a="218006816" 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:15 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) 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; Thu, 15 Jun 2023 03:54:06 -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:54:02 -0700 From: Claudiu Beznea To: , , , , , , , , CC: , , , Claudiu Beznea Subject: [PATCH 3/3] pinctrl: at91-pio4: check return value of devm_kasprintf() Date: Thu, 15 Jun 2023 13:53:33 +0300 Message-ID: <20230615105333.585304-4-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_035416_059430_29338BEA X-CRM114-Status: GOOD ( 10.93 ) 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: 776180848b57 ("pinctrl: introduce driver for Atmel PIO4 controller") Depends-on: 1c4e5c470a56 ("pinctrl: at91: use devm_kasprintf() to avoid potential leaks") Depends-on: 5a8f9cf269e8 ("pinctrl: at91-pio4: use proper format specifier for unsigned int") Signed-off-by: Claudiu Beznea Reviewed-by: Andy Shevchenko --- drivers/pinctrl/pinctrl-at91-pio4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index e40487be2038..fc7d7155bb8d 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -1146,6 +1146,8 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) /* Pin naming convention: P(bank_name)(bank_pin_number). */ pin_desc[i].name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "P%c%u", bank + 'A', line); + if (!pin_desc[i].name) + return -ENOMEM; group->name = group_names[i] = pin_desc[i].name; group->pin = pin_desc[i].number;