Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp685111lqp; Fri, 5 Apr 2024 06:07:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCJLnm1wcpjfG8dbsjzrs4aO4t1ob14EjCrLqzJaZ9td3CUTXH4nCAluJ7GEHG0oYUiZ8PkvgjxQbJ2ApdM2tS9OWjFb31TWaIxO/6Gg== X-Google-Smtp-Source: AGHT+IHf4dGOLTs3Wb1enZKWa1NE7dr4Sv5RF1Lazgt1QXlqTuKygnzfiOK3KbAUksuIUKXfANKr X-Received: by 2002:a17:90a:1648:b0:2a2:981b:2c9e with SMTP id x8-20020a17090a164800b002a2981b2c9emr1414743pje.36.1712322440403; Fri, 05 Apr 2024 06:07:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712322440; cv=pass; d=google.com; s=arc-20160816; b=qpOG1LY7wHDsseYP/QqluipCOhe8L6TbYvQsuBfaQpx+39WmhQOPIxLOIgU+wAyHL2 5S5M8kK/LwL37Or1HjsnHqJFc9y/oV3nwja6oz+j0gLOsP5yXxI6wKDvDagZJyl1oW60 rSdulqRGzt0gg3L0gxssFWwteXMOGI7BayRdCTwjMB7TdLHcYYsff35gjrfB/k8DwBf0 X87zDYkt3RqjNVWE5cXbUBHW3tOgveEt13+I2iOmpnkiUNEicKFFchg3NtFCbMGVutiN BWHOAMfpBlzsrVG6Ln3OJYOtzF28KW0Yji1+hdn/mjzAcjyYgEHlt8emuIvMBvSzBi+/ VW9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=VG02hz6Gv04QD1dPYTAgPeiN4aMOJ98l1TObiQ1bDuQ=; fh=NaqnAaGsckSLUX92vN9UndSGnfE2yKlK6JLH84tJ3wQ=; b=TpxJVJS7AjFypzz/H+i/DiITOBvOseTxAgRubqJqII8HDFDlJvArckgKF48QVgR4PD ZUVKPGSSRFlQhUrPl+V6LbtTUWsuj160FVSFTjvGzDa0HYyEpcWq+sKVO9zf+wEptvih DM6z2sCRkksFZDMTvUKYQwTcFb63/7yL+NOQc1Kgt2iDVU/ifl1dbjVEY7t5wy93mW4x epq1yEJtGwhh8kNsy5TorVh2ivt+RHxKKMFBDfYgtUqSFMlCopxTu8amQF8LJLUJUtJ5 fEUMl8BRIEqzH+BqJIETOcGXNGFipjVtwQP+Qntta479XJSbL9AaZPwKYAjbGnqLfyiQ xeOg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ithwz9jI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133037-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g23-20020a17090ace9700b002a2c3529123si3567849pju.184.2024.04.05.06.07.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 06:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133037-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ithwz9jI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133037-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133037-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4A5CCB21BF5 for ; Fri, 5 Apr 2024 13:01:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B440116D4E6; Fri, 5 Apr 2024 13:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ithwz9jI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D78E216D4D2; Fri, 5 Apr 2024 13:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712322071; cv=none; b=bKwsJhdUpn8dF6oFp6l4lPnt3svMnMNFK+4/+WSqE0UYwJP65YQhyBta0hYBVvwjrirgOIbyiTh6Y+b+gu8quYhu5xJyVV5skM7DkxP/WJcVwrd1dmXRRZiVKn6myq+xTismxmoW0d4PHQlcblDbynSuIC3y6v3SWH+b4r/2lFA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712322071; c=relaxed/simple; bh=KjLmN2j+z29ejJKgU02Fut0SfGnHPqtDrINp5ViYVus=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=idFkNDwf+ErN8bvZNLt2WqyW7PfNL/knWotBIyam48ZAIM/tF02FGwT0AAn+Xo5yl8P3S8SbjMmNQXGq6/d9DcHLEbazptLKOROvO1TBEWnjRplZhxpTUzLyA0seQVeYRU24MvFHX7IpHjFbYb+LQ/k0YXOxt38Hp0qgA979LRE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ithwz9jI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70F06C433C7; Fri, 5 Apr 2024 13:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712322071; bh=KjLmN2j+z29ejJKgU02Fut0SfGnHPqtDrINp5ViYVus=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Ithwz9jIEQF+ZcmXiqmm1y9rQ0NIFn3Do6d0TmS8+NhoM4FP3B4qyai2ruAlf7+c7 CtxwyuGOYKub7W/6Q9gK6MFl+GhbcOUKoJYsw7uk0yzFKLUfeucGzv0TvEjs7g+PYC lQYHUb55kR08R+M1yPn7J1URZ6M8K1io5pMseCxLTRxInXHg4uRq6xnxnWR1A9ABDD Cl7Kab53vL6qaav4hC3GTbEY+c/15dP2TeQYloIeLYaZxNF20B5GWw9NCdK57j8sW3 Sg/cgjrY3r0FilrmIKu16/E0I8RpdjVlMaFuzQgipe76UD8plp/extISaBcepNv7TC FCebpyobqfdmQ== Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-516cdb21b34so2377711e87.1; Fri, 05 Apr 2024 06:01:11 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCXdvWjWdWmpxWEXItI7SXVK/wlGCUd0d7nCxhHBCz+OIwuslB4RRLQVM9t+Op1VYj8wR+X5eFiOL40EX+ddg1V2mP6kVXhHgsYAO4CluXNYJmL8M0RzEu4n8zxU0WtTJR6IbTMp2IS84Q== X-Gm-Message-State: AOJu0YwIbNCGtSNDk9bxE7peXe29kB1dIq+TSKCdmDW4hnAaY84wOL6c ziAvFLZcSNzcxewOt9V38yic5tHXE6peYEGOjnr5IKlYTYix7tNNp/ergBNpC2GWBmHt2zc8jSP p7xb3n7M+NrO5bvfHLDHviWbOeQ== X-Received: by 2002:a19:750b:0:b0:516:d471:18a0 with SMTP id y11-20020a19750b000000b00516d47118a0mr874385lfe.67.1712322064676; Fri, 05 Apr 2024 06:01:04 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240404-dt-cleanup-free-v1-0-c60e6cba8da9@kernel.org> <20240404-dt-cleanup-free-v1-3-c60e6cba8da9@kernel.org> In-Reply-To: From: Rob Herring Date: Fri, 5 Apr 2024 08:00:51 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] of: Use scope based of_node_put() cleanups To: Saravana Kannan Cc: Jonathan Cameron , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Apr 4, 2024 at 6:22=E2=80=AFPM Saravana Kannan wrote: > > On Thu, Apr 4, 2024 at 7:15=E2=80=AFAM Rob Herring wrot= e: > > > > Use the relatively new scope based of_node_put() cleanup to simplify > > function exit handling. Doing so reduces the chances of forgetting an > > of_node_put() and simplifies error paths by avoiding the need for goto > > statements. > > > > Signed-off-by: Rob Herring > > --- > > drivers/of/address.c | 60 ++++++++++++++++---------------------------= -------- > > drivers/of/property.c | 22 ++++++------------- > > 2 files changed, 26 insertions(+), 56 deletions(-) > > > > diff --git a/drivers/of/address.c b/drivers/of/address.c > > index ae46a3605904..f7b2d535a6d1 100644 > > --- a/drivers/of/address.c > > +++ b/drivers/of/address.c > > @@ -491,7 +491,6 @@ static u64 __of_translate_address(struct device_nod= e *dev, > > const __be32 *in_addr, const char *rp= rop, > > struct device_node **host) > > { > > - struct device_node *parent =3D NULL; > > struct of_bus *bus, *pbus; > > __be32 addr[OF_MAX_ADDR_CELLS]; > > int na, ns, pna, pns; > > @@ -504,7 +503,7 @@ static u64 __of_translate_address(struct device_nod= e *dev, > > > > *host =3D NULL; > > /* Get parent & match bus type */ > > - parent =3D get_parent(dev); > > + struct device_node *parent __free(device_node) =3D get_parent(d= ev); > > Can we leave the variable definition where it was? We generally define > all the variables up top. So, defining the one variable in the middle > feels weird. I at least get when we do this inside for/if blocks. But > randomly in the middle feels weird. There's an 'of_node_get(dev);' before this. Ordering wise, we need to hold the ref on the child before we get its parent. I suppose I can also convert that to use the cleanups. I'll have to add another local ptr to do that though. > > Similar comments in other places. Since both kfree() and of_put() can > both handle NULL pointers, I'd be surprised if we HAVE to combine > these lines. https://lore.kernel.org/all/CAHk-=3DwgRHiV5VSxtfXA4S6aLUmcQYEuB67u3BJPJPtuE= Ss1JyA@mail.gmail.com/