Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp670643lqp; Fri, 5 Apr 2024 05:44:32 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVI+ZtdejXKnTzzuRfxgK/FTQyC7KA4FMO7FuZW2HrnpYpKud5S620bkBF1IyPX5Rh10yQHyzfMfxy2QCFt5FnDW32R1BxcV9iSluks/A== X-Google-Smtp-Source: AGHT+IEzAl9Cnv9miK6gMlPiJkDYKMfYXfzFcEISC6Bgpcihh0qEaXi1bpTVp7GbPwgeTPb8Isfm X-Received: by 2002:a17:906:195a:b0:a4e:2d69:e379 with SMTP id b26-20020a170906195a00b00a4e2d69e379mr1080148eje.4.1712321072556; Fri, 05 Apr 2024 05:44:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712321072; cv=pass; d=google.com; s=arc-20160816; b=yU9qsQxYg5LKz+C9p17u3hfB5NUo7tZya3KJVmP7fhxEmSclp4b8IAx4Xe5tDxfEB7 rhgJyfGRNGQZ24ref9Z7GISRM8pmdOC39Wahd961xYHAU2I62VUHYbxTD7Uxq05xr7Uj VL6plDh5kfSZoBm/RKaBIBdZ43EtiiMCm/0C6n/d+9QaZmV9SCXGsuUJGVFFl7m1POzA wrThpjp3HSvq4LH/jPdJ47MVg9YsWw9Q2mh9Hy1SwcBc8bQmHz4o0Gg2YG/Bqco9xORG RX6Tld0xJCkOQmDcunssoqjnOCFLZZgBrtswlgx+SpqzcvpWP3WRuXcVJxqqH6JxjrP6 u2EQ== 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=Sj09ool3E3X3FHcyA0kkPZ6Ua9X1DomhvIynBXXsuhg=; fh=3CtUi3UoOoEN5aE2/vnxGqJUM5d04OOtesJcZWov9EE=; b=nBa3Y8RhyHVRwzzB95f2bzAJrUBTzrWsOHXCc3ZjsuTxTNDk1SaHkewCT4OHx41jJf W57HTEBwMRHNjtyHQHhLXvwForkcS0cOOi7nuVHXuLeFIyQguaUJkqp+s68zreX03xEx 79n9WwzVowgF7ZF1twUP0dNK20JPw33xXNvzyL3/AAwbML6IELeu9gVIk72KG4TO51l2 FuXKo4+o9QiomvpqOUl16J3WyfiuhrQyMEt8myPRPCeYXjtJrdHygQ46frhUgAqPHHhT 57rSRm/qQ48tHZyCgltTlzblpHfFb149HJbiWkm164v7Q6Ce4PcCgz6oo6qHGzqFZ9Hd xhaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MeG3YoD7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133009-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133009-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id dr12-20020a170907720c00b00a4df4a5f583si683760ejc.417.2024.04.05.05.44.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 05:44:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133009-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MeG3YoD7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-133009-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133009-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4CF9D1F22246 for ; Fri, 5 Apr 2024 12:44:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61AAF16D325; Fri, 5 Apr 2024 12:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MeG3YoD7" 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 8426316D315; Fri, 5 Apr 2024 12:44: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=1712321051; cv=none; b=gjli4zcgUVlN0R9rDwHG/sWRetfd97moeivuFcFYzmtAdp0pXTYDI5a6iDU5dijeyI0xOf+RKoKRjmQuJrZTijyXlqg7fDX/B+sQWOpiYiKNgQyBz8zGxT08Lr5Qhd8Da7t72iJyo9S819sg01Zb86QdUsqnLYM8DAXPUJ3Hehw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712321051; c=relaxed/simple; bh=edcCoszjUKd1ECTp0gcxr9Z0qBWJGarmIR7fLPUnxyw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ZFsTrlUvYacmbQb+M08P6Ro0kefJIjCsAPa0IGQ+PK151KHKOxrqEOsJNV9tW4z3HS8Oejt0gVmgG+tRTQoKgkUheMYDzUn3scbMSKN4IeATRFhLX1JSlmhEzVIA/lS9mPfOzUqc3JmgjvLQ8BPxYaAihQHBmXCI/9i14qFIh5I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MeG3YoD7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28731C433C7; Fri, 5 Apr 2024 12:44:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712321051; bh=edcCoszjUKd1ECTp0gcxr9Z0qBWJGarmIR7fLPUnxyw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MeG3YoD79b6FhpaPuptWdVAahekfXkOLNgdnN0RFS0Os+ZFjaRfYZuo5EBibwz84U HKqEXFulS7WGCeyTCovIP1jvSo8Tyix8hKWnOysIMwy4BRzRzI6jzRxRwkRcHs+TJJ btbjM+2SHqTEfh//9Kd1K207bJfjEVLEsxKD2UBxflKWLeFmhjH/kQ6ZsFHnaFMFDW GsQkvOkJvOssyxrX+umH3hy4OQa+fVDnO7/Ctq9ftD0VBm7/HTe6Ar84bqw3sVBJn9 gUbPyHRQULfoNWhe+CtNhoGKlRZuBjhBTcaK6N/5RRcFyNqPEB6lZY2Fz7sA+Rl5eG Oxcyyv9/9GcWw== Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-516d0161e13so1966045e87.3; Fri, 05 Apr 2024 05:44:11 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW3UTQIghuZR1kMVBruVMa3b9Pw03l+L6YDJaDzVWJX8kobrxYvrz68kkIwjOko6Icziv24JJvAm3a0u23kVWKCYvtsDIZnfA+hBKB0Fh0g2zv9nRDnfIUGmxXSWsGFW1Zlk/kUKC96tA== X-Gm-Message-State: AOJu0YzqW7TblJV9gEY07xTClyYYu0LcD3mblRokLFLO7BhbCiJvigf8 mjCNKj87/PHlD2Ei5PKyH8AZjiopNPiiGsrPtjqsyNyHV1z0w5DvkEpEPNETNu9a+CfHkP2K6Vi dkwsaAgGN5HujOEECqmDm+FVHRA== X-Received: by 2002:a05:6512:ac5:b0:515:d3dc:43e with SMTP id n5-20020a0565120ac500b00515d3dc043emr1449133lfu.51.1712321049475; Fri, 05 Apr 2024 05:44:09 -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-2-c60e6cba8da9@kernel.org> In-Reply-To: From: Rob Herring Date: Fri, 5 Apr 2024 07:43:56 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] of: Use scope based kfree() 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:16=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 kfree() cleanup to simplify error > > handling. Doing so reduces the chances of memory leaks and simplifies > > error paths by avoiding the need for goto statements. > > > > Signed-off-by: Rob Herring > > --- > > drivers/of/base.c | 34 ++++++++-------------------------- > > drivers/of/dynamic.c | 11 ++++------- > > drivers/of/resolver.c | 35 +++++++++++++---------------------- > > 3 files changed, 25 insertions(+), 55 deletions(-) > > > > diff --git a/drivers/of/base.c b/drivers/of/base.c > > index 8856c67c466a..20603d3c9931 100644 > > --- a/drivers/of/base.c > > +++ b/drivers/of/base.c > > @@ -16,6 +16,7 @@ > > > > #define pr_fmt(fmt) "OF: " fmt > > > > +#include > > #include > > #include > > #include > > @@ -1393,8 +1394,10 @@ int of_parse_phandle_with_args_map(const struct = device_node *np, > > const char *stem_name, > > int index, struct of_phandle_args *o= ut_args) > > { > > - char *cells_name, *map_name =3D NULL, *mask_name =3D NULL; > > - char *pass_name =3D NULL; > > + char *cells_name __free(kfree) =3D kasprintf(GFP_KERNEL, "#%s-c= ells", stem_name); > > + char *map_name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-map"= , stem_name); > > + char *mask_name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-map= -mask", stem_name); > > + char *pass_name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-map= -pass-thru", stem_name); > > With the scoped stuff, do these function calls need to be in the same > line we are defining these variables? If not, I'd rather that the > calls remain where they were. It feels like a lote to visually parse > and take in from a readability perspective. They don't have to be, but if you don't want to get yelled at by the chief penguin, then yes, they should be together. See the discussions on adding the scoped iterators. But with the C99 adoption, we can move the declaration to where the assignment was original. Rob