From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1025536998C for ; Fri, 31 Jul 2026 07:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785482130; cv=none; b=AiK56irj3i6HEx4eOowPlK8G/Rso3qJXVuf5afS6LHLb1f3tNIe0ySSsA4Nvc7uB2lh1A5H6AEY+QiqaSN77nkojsGWsN1lsifBT6bHkFhhZ3TekKQ78ivh9xNp1ERbs8GlvtoQeYBGu9CfCTFOsUzEOZZrSkLmLecetIjt5nVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785482130; c=relaxed/simple; bh=2E/syk77csIjEkWyr4RdC0J2iasa3xIrAPPLJ0yApf0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nGMxjOEcwJXRHnEuog/ZMsJXAQxocdAKgolIa7eAZv0HbBpH+xhZKQjbYAPCRmSGbEVA5ZyXBR/5yYsq9ePE3+LztS1nZ9KhC128XrWKRWAR+cLfrY0f+HfTLfdGG+Bdm2BWBkT9zEhDHBV60zs4QdgQLTfXHxEFXzLaGSzejmI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G4GE0n5B; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G4GE0n5B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B435E1F00A3A; Fri, 31 Jul 2026 07:15:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1785482128; bh=d80TQvyaCoLgq/NUMpiAgG2jz5ehxRjgCkZbSmCurf0=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=G4GE0n5BFfrCSG2t+7cs/UdLcRtEdB3N0o6ATEq2Th+RQcP+GUYWFuJRKkedFOV5V onYFNzFtbEJwFSrFbJFXvS+YHH1P0WWYuZ5k+USzW7pWgfL6PNZYAfksDY7g+HBNuc tPaHY4ctMK+f9LTpFNiP4lVGiu43HYlTF7qjeRqh8YwAu2QzX5obWguyAR53jB8yb1 3JYspdM6zCVGe28N1bQrRlzNgAw59jLJy7Gtt55LzgE/ZvcoiIzKpFZM3GaHAaa9a5 Rb7/9joURIMqm9FOvUip+GQevyZMNPIZT9mQ0yIA6ZmVo4HTDE5Ljwo4R2zEk4z0c/ jXgu7+befLq2Q== Message-ID: Date: Fri, 31 Jul 2026 09:15:24 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/2] powerpc/pseries: Avoid strlen() in do_{remove,update}_property() To: Thorsten Blum , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Kees Cook Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20260721155346.121975-3-thorsten.blum@linux.dev> <20260721155346.121975-4-thorsten.blum@linux.dev> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20260721155346.121975-4-thorsten.blum@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 21/07/2026 à 17:53, Thorsten Blum a écrit : > Check only the first byte instead of scanning the entire string with > strlen(). > > Signed-off-by: Thorsten Blum Reviewed-by: Christophe Leroy (CS GROUP) > --- > arch/powerpc/platforms/pseries/reconfig.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c > index 7faebcffc9df..18e3f1a036e3 100644 > --- a/arch/powerpc/platforms/pseries/reconfig.c > +++ b/arch/powerpc/platforms/pseries/reconfig.c > @@ -307,7 +307,7 @@ static int do_remove_property(char *buf, size_t bufsize) > if (tmp) > *tmp = '\0'; > > - if (strlen(buf) == 0) > + if (*buf == '\0') Can use !*buf instead. > return -EINVAL; > > return of_remove_property(np, of_find_property(np, buf, NULL)); > @@ -330,7 +330,7 @@ static int do_update_property(char *buf, size_t bufsize) > if (!next_prop) > return -EINVAL; > > - if (!strlen(name)) > + if (*name == '\0') Can use !*name instead. > return -ENODEV; > > newprop = new_property(name, length, value, NULL);