From: sashiko-bot@kernel.org
To: "Griffin Kroah-Hartman" <griffin.kroah@fairphone.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org,
dmitry.torokhov@gmail.com, krzk+dt@kernel.org,
conor+dt@kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH RFC 1/4] regulator: add devm_fwnode family of functions
Date: Fri, 08 May 2026 21:08:37 +0000 [thread overview]
Message-ID: <20260508210838.4A149C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260508-gpiokeys-vdd-supply-v1-1-0bb32e8e6428@fairphone.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The fallback stubs for `devm_fwnode_regulator_get` and its variants incorrectly return `NULL` instead of `ERR_PTR(-ENODEV)` when `CONFIG_OF` is disabled but `CONFIG_REGULATOR` is enabled, leading to a guaranteed kernel panic on non-OF systems.
--
commit f8899ceec7e07e935c3ae44032450cd2b8f68352
Author: Griffin Kroah-Hartman <griffin.kroah@fairphone.com>
regulator: add devm_fwnode family of functions
Add devm_fwnode_regulator_get and variants.
These function wrappers allow regulators to be accessed from the fwnode
struct without any casts.
> diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
> --- a/include/linux/regulator/consumer.h
> +++ b/include/linux/regulator/consumer.h
[ ... ]
> +static inline struct regulator *__must_check
> +devm_fwnode_regulator_get(struct device *dev, struct fwnode_handle *fwnode,
> + const char *id)
> +{
> + return NULL;
> +}
Will returning NULL here instead of ERR_PTR(-ENODEV) cause a panic on non-OF
systems?
If CONFIG_REGULATOR is enabled but CONFIG_OF is disabled, a driver calling
this will get NULL. Since drivers typically check the return value with
IS_ERR(), IS_ERR(NULL) evaluates to false. The driver would assume it
successfully acquired a valid regulator.
Later, when the driver calls regulator_enable(), it will pass this NULL
pointer. Since CONFIG_REGULATOR is enabled, regulator_enable() is not stubbed
out and will unconditionally dereference the pointer, leading to a NULL
pointer dereference.
Should these stubs return ERR_PTR(-ENODEV) instead to safely signal the
absence of a regulator and match the expected regulator API semantics?
> +
> +static inline struct regulator *__must_check
> +devm_fwnode_regulator_get_exclusive(struct device *dev, struct fwnode_handle *fwnode,
> + const char *id)
> +{
> + return NULL;
> +}
> +
> +static inline struct regulator *__must_check
> +devm_fwnode_regulator_get_optional(struct device *dev, struct fwnode_handle *fwnode,
> + const char *id)
> +{
> + return NULL;
> +}
Does returning NULL for the optional and exclusive variants violate the
regulator API semantics which require returning ERR_PTR(-ENODEV) to safely
signal the absence of a regulator?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260508-gpiokeys-vdd-supply-v1-0-0bb32e8e6428@fairphone.com?part=1
next prev parent reply other threads:[~2026-05-08 21:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-08 12:53 [PATCH RFC 0/4] Add regulator support to gpio-keys Griffin Kroah-Hartman
2026-05-08 12:53 ` [PATCH RFC 1/4] regulator: add devm_fwnode family of functions Griffin Kroah-Hartman
2026-05-08 13:31 ` Mark Brown
2026-05-08 21:08 ` sashiko-bot [this message]
2026-05-08 12:53 ` [PATCH RFC 2/4] dt-bindings: input: gpio-keys: Add vdd-supply Griffin Kroah-Hartman
2026-05-08 12:53 ` [PATCH RFC 3/4] Input: gpio-keys - add regulator to gpio_keys Griffin Kroah-Hartman
2026-05-08 13:44 ` Mark Brown
2026-05-15 11:41 ` Griffin Kroah-Hartman
2026-05-16 2:47 ` Mark Brown
2026-05-08 21:36 ` sashiko-bot
2026-05-08 12:53 ` [PATCH RFC 4/4] arm64: dts: qcom: milos-fairphone-fp6: add supply for Hall Effect sensor Griffin Kroah-Hartman
2026-05-08 21:56 ` sashiko-bot
2026-05-11 11:46 ` Konrad Dybcio
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=20260508210838.4A149C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=griffin.kroah@fairphone.com \
--cc=krzk+dt@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.