Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp50860lqe; Fri, 5 Apr 2024 12:13:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbOvAucx5mQO1givhW+TV259SKu9nQmnj4nUNL8fnYvBXVXJSB9k4i/kuf+tYc7TrfwWCBH0TUJiJ7jeuC4aVnndC5oCESuSxtsiqgSg== X-Google-Smtp-Source: AGHT+IFjX9CJCvpRNqjnoXePTPwnzI+xTU5UwaBMiEZT7OEY6rwuu7+r2KBqsKU/7XA9x6eAdBib X-Received: by 2002:a05:6512:3e17:b0:515:9150:ecc1 with SMTP id i23-20020a0565123e1700b005159150ecc1mr2090698lfv.24.1712344408274; Fri, 05 Apr 2024 12:13:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712344408; cv=pass; d=google.com; s=arc-20160816; b=WcDgzS8f9vjlshYuX3CEuSmC1F0RWPxukcKok4qBJsdUEIP+qroMT26Uugd3YPdjGk 4Kw/SsKiAbF8BjZEGw/4VM4MjYXiqjSMFkOX/ns0GNPVUvdqVSoRknLduRykaBbDI44d zYcead5dit/T6DM4RLVOgs8LiJuQddF1+DmAIRj6fpFmbVGOlxTe9lgz4zu+KBdJEg2D gWNMBisxKstgQ/J91IKIl5aT3zGL6q9VVy9IbyqIInGwd5epxXieKbsxjetycVjDPbLw +5CM21OdX6q0tUgzjtEgF9v9dGc/wsJ3EY2mrCQrxSotskYfKCfr7wTVZB4zAC4E2eXZ AK6A== 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=5OftswQMoXlzPzi1h0xRfVUEMp13ATiDevvRviGfB5Y=; fh=YNYePlqTwfhH5ZWjWhgpKHynNCEOhjHAwm1M0kMAJOQ=; b=Qrwe3aBvecPCYIUC//8N+VZWbz3whM2FeEAv9SISiozGXDu0loPJlUHdo0Uq6juTLg PlfHaGhvZyV2RMJ40g+FSprc5nPE3iG/3JVmpMQ/OUsVq6vzK+Y5nSp38a37wYLjIXm0 uZcFHSMdi7VJxbXjCJO/JlDvcxYap1mhyut2hYO9guzgReAhZ7bHzrd7FDd8sanVDNKS m0fl1YtsRL0CwbVXksmDvErJrsWiYxeoaXK5yXZikNiesYDLdGpG/E9pwfEHiaVpohUX Sm/L3Wa0Ms2npwqIcqP+5KrEouuVMe3CgDSHIukafX9yD0ujeaGv3xZV4Zvr1MwGE7ir TabA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2UlCSDoz; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133513-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ha8-20020a170906a88800b00a4e25f5f461si963691ejb.270.2024.04.05.12.13.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 12:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133513-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=@google.com header.s=20230601 header.b=2UlCSDoz; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133513-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 C81591F21AD3 for ; Fri, 5 Apr 2024 19:13:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 86559172BB1; Fri, 5 Apr 2024 19:13:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2UlCSDoz" Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37BFD17276C for ; Fri, 5 Apr 2024 19:13:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712344399; cv=none; b=sPVtJ02XJ6vCfJiNCn+J5boWHg8TgkIxwyTcSTtQsaUuvs+LXA8RlF32vd3D2TpkBrMPg6QYVwxdHELO6NGhs+kjYP/BHHJtzv8EOkUKxrz7xlZHvhHf4h0gzpKbtWDfDEz2h9PeuOf+hXIyMFpwyYb+uTC7eGkAHb8dnUpH07U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712344399; c=relaxed/simple; bh=tQzOvHwoLiw8NG9JFXA4dymZzAKwe0NEj/YFfCcxuXc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YtNera9A3K3aio2h4JcQHJ3G1YTatnuXlv6+7xjbkrHmq36lcg5ryD++iI9ZxihQKzm5+dGNjxmsiKWaUpfi0JlFGu+eD9IKVHBboC9qbUB5MqAlUDMKKXqVpHQkccnSPEIYZCUUv7y5vHye5cSGKKeyy1cs2NPgpNQV93eltTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2UlCSDoz; arc=none smtp.client-ip=209.85.160.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-430d3fcc511so45381cf.1 for ; Fri, 05 Apr 2024 12:13:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712344397; x=1712949197; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5OftswQMoXlzPzi1h0xRfVUEMp13ATiDevvRviGfB5Y=; b=2UlCSDoztHB5zMRJMZE07Q0vASMjO8bHjr5txXxQjmhTKTFaF4BCNqHad2edGsYA1i o1eGGXB9ybDAt9RsdpCuRnM9tg3QQoJik5tGxBES7Eeh1vAV1QUja/493Hff8xxcuOPD hCquTcoDRhGn9z6hOqMVu7T49nUHTz7fdB9H7baBd0znogANbQ46c2Y16jgKP0s9/G2U +zjdkyVZfPMA9cuX0Y2hVAbJsILHjt3Uphyig0p7vYp2VA0W1hbJKPGLgKJfNEBTGH6w BcXKeLMvpSWP7+4ioN9DydKDzq2e+hb+3/QN2zHIrNJwXwFEZs0XVieHVDncqps/MyAH 9inQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712344397; x=1712949197; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5OftswQMoXlzPzi1h0xRfVUEMp13ATiDevvRviGfB5Y=; b=ZmJNcMAP2zrFRQyl8jCyAkAMfD6S1afVCI5dc3tcrobrOABHiTBZz90TJ8vZPKcIcD IIMjNNpCKlIG4aG7+BZoXyehzkC12/5Vvq0KF73r9QrQgfvMvSvpugQLi5xrP8PTiv2D Be/MKEt9cj7P4AbP1HKT9n5qEySFqyNOgpkOLpwkMKtfP3FiohHI96ELXcakeIwyocV4 +4gPx3qyhYxKlKIWfU9WA9tplrR1wwJpbzFtXLs8uRSjZ7+b2+hIIGZz5Dw6Y3bfAQLH gGplY1VzjbnH2GFvkp9BJ+rOX1BaXZsBqA2CxED9UcwsmCQSvcC+RAvTDcC3uMIIngMA yajg== X-Forwarded-Encrypted: i=1; AJvYcCWvoJY7rvoTl0FkaeWZVkoWAzvZzOzltEqbfOhK66ssDb2kgFy16t2veaNK/i6wIEzD1VNYcsoX0WRVSSZ2r3h4TpzkjTld39AivRDG X-Gm-Message-State: AOJu0Ywi5aPliOtwhbBu1edqGRiN7u3AbWFA2BTch27N7nrVYVhauEY/ XKH6IzyDUqy5Ky0gjq6m5cZMLyMOY8gCmxQ/3CyqUNGUrEefE9TWrepjMO94rFPBb+s7LObJcdB SHIHfih857rIL7soIgZnP5xfWaZToIXEoIsiM8KMTR4nZg5E1bw== X-Received: by 2002:a05:622a:1e87:b0:431:30e4:f2f0 with SMTP id bz7-20020a05622a1e8700b0043130e4f2f0mr25017qtb.7.1712344396942; Fri, 05 Apr 2024 12:13:16 -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: Saravana Kannan Date: Fri, 5 Apr 2024 12:12:38 -0700 Message-ID: Subject: Re: [PATCH 2/3] of: Use scope based kfree() cleanups To: Rob Herring 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 Fri, Apr 5, 2024 at 5:44=E2=80=AFAM Rob Herring wrote: > > 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 wr= ote: > > > > > > 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 struc= t device_node *np, > > > const char *stem_name, > > > int index, struct of_phandle_args = *out_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= -cells", stem_name); > > > + char *map_name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-ma= p", stem_name); > > > + char *mask_name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-m= ap-mask", stem_name); > > > + char *pass_name __free(kfree) =3D kasprintf(GFP_KERNEL, "%s-m= ap-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. Thanks for the context and the link in the other email. Review-by without reservations. -Saravana