Re: [PATCH v5 3/7] firmware: samsung: acpm: Fix dummy stubs to return ERR_PTR
From: Arnd Bergmann
Date: Fri May 29 2026 - 07:57:40 EST
On Tue, May 5, 2026, at 15:13, Tudor Ambarus wrote:
> Sashiko identified a potential NULL pointer dereference [1].
>
> The dummy stub implementation for devm_acpm_get_by_node() returns NULL
> when CONFIG_EXYNOS_ACPM_PROTOCOL is disabled.
I meant to comment on this yesterday as well.
Having stub functions like this return NULL is a common way to
define optional interfaces, where callers still work when the
feature is disabled, though this clearly does not work for
acpm because some callers have a NULL pointer dereference
when compile testing.
My preferred solution to this type of problem would be to
just remove the stub helpers and drop the ||COMPILE_TEST
from the one user that calls them, see below.
The point here is that CONFIG_EXYNOS_ACPM_PROTOCOL already
supports compile-testing itself, and all (both) drivers using
it clearly require the support, so this just simplifies
the option space without losing any build coverage.
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
diff --git a/drivers/clk/samsung/Kconfig b/drivers/clk/samsung/Kconfig
index 70a8b82a0136..198d8b621289 100644
--- a/drivers/clk/samsung/Kconfig
+++ b/drivers/clk/samsung/Kconfig
@@ -97,7 +97,7 @@ config EXYNOS_CLKOUT
config EXYNOS_ACPM_CLK
tristate "Clock driver controlled via ACPM interface"
- depends on EXYNOS_ACPM_PROTOCOL || (COMPILE_TEST && !EXYNOS_ACPM_PROTOCOL)
+ depends on EXYNOS_ACPM_PROTOCOL
help
This driver provides support for clocks that are controlled by
firmware that implements the ACPM interface.
diff --git a/include/linux/firmware/samsung/exynos-acpm-protocol.h b/include/linux/firmware/samsung/exynos-acpm-protocol.h
index 83cbd425b652..c73aea30d960 100644
--- a/include/linux/firmware/samsung/exynos-acpm-protocol.h
+++ b/include/linux/firmware/samsung/exynos-acpm-protocol.h
@@ -68,22 +68,8 @@ struct acpm_handle {
struct device;
-#if IS_ENABLED(CONFIG_EXYNOS_ACPM_PROTOCOL)
struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
struct device_node *np);
struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev);
-#else
-
-static inline struct acpm_handle *devm_acpm_get_by_node(struct device *dev,
- struct device_node *np)
-{
- return ERR_PTR(-ENODEV);
-}
-
-static inline struct acpm_handle *devm_acpm_get_by_phandle(struct device *dev)
-{
- return ERR_PTR(-ENODEV);
-}
-#endif
#endif /* __EXYNOS_ACPM_PROTOCOL_H */