From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D484C4167D for ; Tue, 14 Nov 2023 11:48:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232714AbjKNLsk (ORCPT ); Tue, 14 Nov 2023 06:48:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjKNLsi (ORCPT ); Tue, 14 Nov 2023 06:48:38 -0500 Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAAF1A7; Tue, 14 Nov 2023 03:48:35 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3821AFF803; Tue, 14 Nov 2023 11:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1699962514; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ecc2U8XKNAiKPYVEs6kOx9hM2XH9Tt8TCuws1240YTw=; b=WTnPxPVyckP+A0BzC7eaUF/2H8p8/YNg/sg7BmqSWyd7UP8TY5OwzJRhkgq+AYfexSM5Yr js51iQf9AqX1FcmCaQm8LmT5XNQVOceD75MYOjJGe9Niyqm7ppgaSdY+uUU2TkcDn13lUK sS4YdHGe7f3amOLybBZ9xcsB1b7VR4KROu5tiV3cZRJjUx0xzkSIWJN491T7B1EUkf5mTP fa8FQInIoiC9c6gYc5oU3ct2BF3QbQV1KnvjmKkuFUREDpzJdsM5l8DBVCqcIxnxjnE2gJ XXJOkgslyXRWnb0tZJkTVVqzrke6aSLEkYgLpfmBc6fJGhAKv1p5d26CMQwI4Q== Date: Tue, 14 Nov 2023 12:48:32 +0100 From: Herve Codina To: Sakari Ailus Cc: Saravana Kannan , Petr Mladek , Steven Rostedt , Andy Shevchenko , Rasmus Villemoes , Sergey Senozhatsky , "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Allan Nielsen , Horatiu Vultur , Steen Hegelund , Thomas Petazzoni , stable@vger.kernel.org Subject: Re: [PATCH 1/1] lib/vsprintf: Fix %pfwf when current node refcount == 0 Message-ID: <20231114124832.40d4ced4@bootlin.com> In-Reply-To: References: <20231114110456.273844-1-herve.codina@bootlin.com> Organization: Bootlin X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sakari, On Tue, 14 Nov 2023 11:28:43 +0000 Sakari Ailus wrote: > > --- a/lib/vsprintf.c > > +++ b/lib/vsprintf.c > > @@ -2108,8 +2108,8 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf, > > { > > int depth; > > > > - /* Loop starting from the root node to the current node. */ > > - for (depth = fwnode_count_parents(fwnode); depth >= 0; depth--) { > > + /* Loop starting from the root node to the parent of current node. */ > > + for (depth = fwnode_count_parents(fwnode); depth > 0; depth--) { > > struct fwnode_handle *__fwnode = > > fwnode_get_nth_parent(fwnode, depth); > > How about, without changing the loop: > > /* > * Only get a reference for other nodes, fwnode refcount > * may be 0 here. > */ > struct fwnode_handle *__fwnode = > depth ? fwnode_get_nth_parent(fwnode, depth) : fwnode; > > > > > @@ -2121,6 +2121,16 @@ char *fwnode_full_name_string(struct fwnode_handle *fwnode, char *buf, > > fwnode_handle_put(__fwnode); > > And: > > if (__fwnode != fwnode) > fwnode_handle_put(__fwnode); > Sure. I will just change to keep the both tests consistent. I mean test with depth or test with __fwnode != fwnode but avoid mixing them. What do you think about testing using depth in all cases and so: if (depth) fwnode_handle_put(__fwnode); Best regards, Hervé