From: sashiko-bot@kernel.org
To: "Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, linux-gpio@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 5/9] of: property: implement the .property_get_names() fwnode operation
Date: Wed, 04 Nov 2026 14:18:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-197420@kernel.org> (raw)
In-Reply-To: <20261104-fwnode-for-each-prop-v1-5-6e28fe1c72c4@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] of: property: of_fwnode_property_get_names() sets *props to ZERO_SIZE_PTR
--
commit 9f35cc327cc9ae6d6d25a8e2fba2753d5485053e
Author: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
of: property: implement the .property_get_names() fwnode operation
This commit implements the .property_get_names() fwnode callback for OF
nodes by iterating over the device node properties and returning a newly
allocated string array of property names.
> diff --git a/drivers/of/property.c b/drivers/of/property.c
> index 45e55f6184880..16c9c307633bd 100644
> --- a/drivers/of/property.c
> +++ b/drivers/of/property.c
[ ... ]
> @@ -1120,6 +1121,34 @@ of_fwnode_property_read_string_array(const struct fwnode_handle *fwnode,
> of_property_count_strings(node, propname);
> }
>
> +static int of_fwnode_property_get_names(const struct fwnode_handle *fwnode,
> + char ***props)
> +{
> + const struct device_node *node = to_of_node(fwnode);
> + struct property *prop;
> + int count = 0, i = 0;
> + char **names;
> +
> + for_each_property_of_node(node, prop)
> + count++;
> +
> + names = kcalloc(count, sizeof(*names), GFP_KERNEL);
> + if (!names)
> + return -ENOMEM;
> +
> + for_each_property_of_node(node, prop) {
> + names[i] = kstrdup(prop->name, GFP_KERNEL);
> + if (!names[i]) {
> + kfree_strarray(names, i);
> + return -ENOMEM;
> + }
> + i++;
> + }
> +
> + *props = names;
> + return count;
> +}
[Severity: Medium]
What happens in of_fwnode_property_get_names() if node->properties is NULL
(for example, on a dynamically created empty node from
of_changeset_create_node() or a node whose properties were removed via
of_remove_property())?
When count is 0, kcalloc(0, sizeof(*names), GFP_KERNEL) returns
ZERO_SIZE_PTR, which passes the !names check and sets *props to
ZERO_SIZE_PTR before returning 0.
However, the documentation for struct fwnode_operations in
include/linux/fwnode.h states:
* @property_get_names: Retrieve the list of all properties of this firmware
* node. On success: returns the number of properties and
* sets *props to an array of NULL-terminated strings that
* must be freed by the user with kfree_strarray(). If
* there are no properties, 0 is returned and the props
* pointer is not changed. Returns negative error number on
* failure.
Should of_fwnode_property_get_names() return 0 early when count is 0 so
that *props is left untouched?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261104-fwnode-for-each-prop-v1-0-6e28fe1c72c4@oss.qualcomm.com?part=5
next prev parent reply other threads:[~2026-11-04 14:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-04 14:03 [PATCH 0/9] gpio: make gpiolib-shared more fwnode-centric Bartosz Golaszewski
2026-11-04 14:03 ` [PATCH 1/9] device property: fix fwnode_name_eq() for empty node names Bartosz Golaszewski
2026-11-04 14:03 ` [PATCH 2/9] lib: string_helpers: implement a CLASS() for string arrays Bartosz Golaszewski
2026-11-04 14:03 ` [PATCH 3/9] fwnode: define the property_get_names() operation Bartosz Golaszewski
2026-11-04 14:03 ` [PATCH 4/9] device property: provide fwnode_property_get_names() Bartosz Golaszewski
2026-11-04 14:12 ` sashiko-bot
2026-11-04 14:03 ` [PATCH 5/9] of: property: implement the .property_get_names() fwnode operation Bartosz Golaszewski
2026-11-04 14:18 ` sashiko-bot [this message]
2026-11-04 14:03 ` [PATCH 6/9] fwnode: define the count_references() " Bartosz Golaszewski
2026-11-04 14:03 ` [PATCH 7/9] device property: provide fwnode_property_count_references() Bartosz Golaszewski
2026-11-04 14:03 ` [PATCH 8/9] of: property: implement the count_references() fwnode operation Bartosz Golaszewski
2026-11-04 15:33 ` Rob Herring
2026-11-04 14:03 ` [PATCH 9/9] gpio: shared: generalize most code to firmware nodes Bartosz Golaszewski
2026-11-04 14:15 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-197420@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox