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;