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 6CC42C6FA89 for ; Wed, 7 Sep 2022 11:15:53 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5C1A684A5C; Wed, 7 Sep 2022 13:15:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="fcq/HZHY"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1923784A5C; Wed, 7 Sep 2022 13:15:50 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1F7A68494A for ; Wed, 7 Sep 2022 13:15:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B5D2CB81BEC; Wed, 7 Sep 2022 11:15:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F088C433C1; Wed, 7 Sep 2022 11:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662549345; bh=ULsOlbmZnllEHE6E8aiyGgjt6jO1J9Wyc+3GFek4ORw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fcq/HZHYfnCyRbnQRFwB+MCJNuvYD+qncUllFb8lNRSaEEnKBKbnTxitmf1yK+gl7 B3yo0jT5if1i6lrACjN+w4CJmOnAN0XhO9ug6GMEOMYWRAalQUm6WhFQLBc5SOEEi6 v/jbzoyk+J2RCINGq8qJhhbsIbnUjzti2o32wsKtuE9Zvdn50gW4TmI1QIGfWBKU9O tE2bbZovA6KT42gNoo4h4/uPOAO0sHO/oK6Hq1vvU+w3Yy/BiSvCLPd63HzhdwvU+q EXpQxPjVYMiTNN9bQ6bfz7xQuk9lVhHugK8NHUk0sxwT1Af2KX3e0lAvvx06zB/xyL Qc7oGFDAAg3eQ== Received: by pali.im (Postfix) id 666637F0; Wed, 7 Sep 2022 13:15:42 +0200 (CEST) Date: Wed, 7 Sep 2022 13:15:42 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: John Keeping Cc: u-boot@lists.denx.de, Stefan Roese Subject: Re: [PATCH] pinctrl: fix buffer size for pinctrl_generic_set_state_prefix() Message-ID: <20220907111542.4fwlilrvfpkro2fv@pali> References: <20220907111142.1980540-1-john@metanate.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220907111142.1980540-1-john@metanate.com> User-Agent: NeoMutt/20180716 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 On Wednesday 07 September 2022 12:11:42 John Keeping wrote: > 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. You are right. Not sure why I put there sizeof("pins") (maybe old version when name was only pins). Reviewed-by: Pali Rohár > 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 >