From nobody Sat Feb 7 22:01:51 2026 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 39CBE12CD8B; Wed, 31 Jul 2024 19:13:37 +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=1722453217; cv=none; b=a9dM/xW5AQ8M82EZvtJh3ro2UxCPGhIFS2iR1snAawlRlHWcm4soka7ljnXDBSQzr9Y11t4XjnMybprRX/MpTpbIUwSaOu6LQPGEETdVs/EaAhIcKS2z11hL7HTSwgN8s/QRndBQVvt4dkYPogGu++fuTMHLJUWHJ6HRrrHB9zI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722453217; c=relaxed/simple; bh=hOU/2ld5kf2bldZq16dLixHCIlSUJ7gODRhc167/YF0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=CJ+fi2u+725S8MMWtaiCYZLQEeRfkMBo1QRaIvC+wS2JKKOSM9ichK4XooIpRqfo8U88Se5MrRF1XjuZZIoZi+SUv/m2uF8L+haSEYexaWPOdV3RNlroDwT6JTQK0PdBmfrP/uDnUL5oraxSpge3iS75OeanL0B/A+gPXvwmlZo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SeeZtwBA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SeeZtwBA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C26D8C4AF09; Wed, 31 Jul 2024 19:13:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722453217; bh=hOU/2ld5kf2bldZq16dLixHCIlSUJ7gODRhc167/YF0=; h=From:To:Cc:Subject:Date:From; b=SeeZtwBAmUfIkYk4PWKWiUXJRmHJEJygOK9WabmeYbzh+4+g9b04ceZJSs/cjCUpO UiPPoiHvGdkV0pmf+o12DwPaQRoy/Fj6FIsTrd4DuNH58tnknvGQ8abS6Rh6+UNOkx ce2cBqSweF6Naa1EDEyoDP1MmeJi+EHbAnsYpfVK0fkV1ViAlD/2NZRGpiNeTfx/FE quWOrGxalVSGTWhZgTt/iazEg8hsjB5lf9DEUMRqnHLeCo00HA7afKyWXGDK1g2k8L 75qK96YtzBjPJvGoz77TMBivuxj39Hgf3D9jKAYHzfdqwztncskhBmkq53O3RYOx8R O2eh+4UMZjAyA== From: "Rob Herring (Arm)" To: Linus Walleij , Bartosz Golaszewski Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpio: Use of_property_present() Date: Wed, 31 Jul 2024 13:12:41 -0600 Message-ID: <20240731191312.1710417-3-robh@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use of_property_present() to test for property presence rather than of_find_property(). This is part of a larger effort to remove callers of of_find_property() and similar functions. of_find_property() leaks the DT struct property and data pointers which is a problem for dynamically allocated nodes which may be freed. Signed-off-by: Rob Herring (Arm) --- drivers/gpio/gpiolib-of.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index f6af5e7be4d1..6683e531df52 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -1058,13 +1058,13 @@ static int of_gpiochip_add_pin_range(struct gpio_ch= ip *chip) int index =3D 0, ret, trim; const char *name; static const char group_names_propname[] =3D "gpio-ranges-group-names"; - struct property *group_names; + bool has_group_names; =20 np =3D dev_of_node(&chip->gpiodev->dev); if (!np) return 0; =20 - group_names =3D of_find_property(np, group_names_propname, NULL); + has_group_names =3D of_property_present(np, group_names_propname); =20 for (;; index++) { ret =3D of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, @@ -1085,7 +1085,7 @@ static int of_gpiochip_add_pin_range(struct gpio_chip= *chip) =20 if (pinspec.args[2]) { /* npins !=3D 0: linear range */ - if (group_names) { + if (has_group_names) { of_property_read_string_index(np, group_names_propname, index, &name); @@ -1123,7 +1123,7 @@ static int of_gpiochip_add_pin_range(struct gpio_chip= *chip) break; } =20 - if (!group_names) { + if (!has_group_names) { pr_err("%pOF: GPIO group range requested but no %s property.\n", np, group_names_propname); break; --=20 2.43.0