Linux driver-core infrastructure
 help / color / mirror / Atom feed
* [PATCH] device property: set fwnode->secondary to NULL in fwnode_init()
@ 2026-05-06 11:57 Bartosz Golaszewski
  2026-05-06 13:10 ` Andy Shevchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2026-05-06 11:57 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich,
	Andy Shevchenko, Daniel Scally, Heikki Krogerus, Sakari Ailus,
	Len Brown, Rob Herring, Saravana Kannan
  Cc: driver-core, linux-acpi, linux-kernel, brgl, Bartosz Golaszewski,
	stable

If a firmware node is allocated on the stack (for instance: temporary
software node whose life-time we control) or on the heap - but using a
non-zeroing allocation function - and initialized using fwnode_init(),
its secondary pointer will contain uninitalized memory which likely will
be neither NULL nor IS_ERR() and so may end up being dereferenced (for
example: in dev_to_swnode()). Set fwnode->secondary to NULL on
initialization.

Cc: stable@vger.kernel.org
Fixes: 01bb86b380a3 ("driver core: Add fwnode_init()")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
 include/linux/fwnode.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 80b38fbf2121..31df7608737e 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -208,6 +208,7 @@ struct fwnode_operations {
 static inline void fwnode_init(struct fwnode_handle *fwnode,
 			       const struct fwnode_operations *ops)
 {
+	fwnode->secondary = NULL;
 	fwnode->ops = ops;
 	INIT_LIST_HEAD(&fwnode->consumers);
 	INIT_LIST_HEAD(&fwnode->suppliers);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-05-08  0:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-06 11:57 [PATCH] device property: set fwnode->secondary to NULL in fwnode_init() Bartosz Golaszewski
2026-05-06 13:10 ` Andy Shevchenko
2026-05-06 13:16   ` Bartosz Golaszewski
2026-05-06 19:26 ` Rafael J. Wysocki
2026-05-07  7:25 ` Sakari Ailus
2026-05-08  0:03 ` Danilo Krummrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox