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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB15CC6FA89 for ; Wed, 7 Sep 2022 11:11:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A696C8494A; Wed, 7 Sep 2022 13:11:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=metanate.com header.i=@metanate.com header.b="vsFdKPhG"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2E80184A6B; Wed, 7 Sep 2022 13:11:53 +0200 (CEST) Received: from metanate.com (unknown [IPv6:2001:8b0:1628:5005::111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1C6B9848DC for ; Wed, 7 Sep 2022 13:11:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=metanate.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=john@metanate.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=metanate.com; s=stronger; h=Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Content-Type:Reply-To:Content-ID:Content-Description: In-Reply-To:References; bh=/FROV30U3tqZC0CnLVzfs1CdQ+IAeosS73Yy/pafyVo=; b=vs FdKPhGK25+u6hJTdJLuRSwgWDg4pW8deofPUoUE8wEr10/WiZd4+AzQb7CHNZcXJI85m02O8vIO2L G2pqh/+LurR919J4LPIT/cqp8AF8YrJiLNnNj99FRShNrJJ7Pb5FrEB3eIbvCrEIT+BAece4EwhP5 VyKEaMf1L9erO1u4U/W172xLZnxZZySLFHkBoWdSRtXIplu3sECNLhjUtacR7HbWaZJrYgDQotzWA XHgYheRnQN81m3iS+o/Ezf5GwVs+mFovVbvG2qsWh4QaNp0fjzLtTTNNlagsk0LaHBnJh0NyvGRPN L0+1p0kQ5RlmVuSX765FzSyO3vfZA7ZA==; Received: from dougal.metanate.com ([192.168.88.1] helo=donbot.metanate.com) by email.metanate.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1oVsyD-0005d5-Dz; Wed, 07 Sep 2022 12:11:50 +0100 From: John Keeping To: u-boot@lists.denx.de Cc: John Keeping , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Stefan Roese Subject: [PATCH] pinctrl: fix buffer size for pinctrl_generic_set_state_prefix() Date: Wed, 7 Sep 2022 12:11:42 +0100 Message-Id: <20220907111142.1980540-1-john@metanate.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated: YES X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This buffer has the concatenated prefix and name written into it, so it must be large enough to cover both strings plus the terminating NUL. Fixes: 92c4a95ec7 ("pinctrl: Add new function pinctrl_generic_set_state_prefix()") Signed-off-by: John Keeping --- drivers/pinctrl/pinctrl-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c index ec21d4ff83..8909b57810 100644 --- a/drivers/pinctrl/pinctrl-generic.c +++ b/drivers/pinctrl/pinctrl-generic.c @@ -237,7 +237,7 @@ enum pinmux_subnode_type { static const char *alloc_name_with_prefix(const char *name, const char *prefix) { if (prefix) { - char *name_with_prefix = malloc(strlen(prefix) + sizeof("pins")); + char *name_with_prefix = malloc(strlen(prefix) + strlen(name) + 1); if (name_with_prefix) sprintf(name_with_prefix, "%s%s", prefix, name); return name_with_prefix; -- 2.37.3