* [PATCH v2] device property: initialize the remaining fields of fwnode_handle in fwnode_init()
@ 2026-05-11 7:49 Bartosz Golaszewski
2026-05-11 19:58 ` Danilo Krummrich
0 siblings, 1 reply; 2+ messages in thread
From: Bartosz Golaszewski @ 2026-05-11 7:49 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, Greg Kroah-Hartman,
Danilo Krummrich, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
Sakari Ailus, Saravana Kannan, Rob Herring
Cc: linux-acpi, driver-core, 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. While at it: initialize the remaining fields of struct
fwnode_handle too just to be sure.
Cc: stable@vger.kernel.org
Fixes: 01bb86b380a3 ("driver core: Add fwnode_init()")
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
Changes in v2:
- initialize all remaining fields in struct fwnode_handle too
include/linux/fwnode.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h
index 80b38fbf2121..c30a9baafc0d 100644
--- a/include/linux/fwnode.h
+++ b/include/linux/fwnode.h
@@ -208,9 +208,12 @@ struct fwnode_operations {
static inline void fwnode_init(struct fwnode_handle *fwnode,
const struct fwnode_operations *ops)
{
+ fwnode->secondary = NULL;
fwnode->ops = ops;
+ fwnode->dev = NULL;
INIT_LIST_HEAD(&fwnode->consumers);
INIT_LIST_HEAD(&fwnode->suppliers);
+ fwnode->flags = 0;
}
static inline void fwnode_set_flag(struct fwnode_handle *fwnode,
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] device property: initialize the remaining fields of fwnode_handle in fwnode_init()
2026-05-11 7:49 [PATCH v2] device property: initialize the remaining fields of fwnode_handle in fwnode_init() Bartosz Golaszewski
@ 2026-05-11 19:58 ` Danilo Krummrich
0 siblings, 0 replies; 2+ messages in thread
From: Danilo Krummrich @ 2026-05-11 19:58 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Rafael J . Wysocki, Len Brown, Greg Kroah-Hartman,
Danilo Krummrich, Andy Shevchenko, Daniel Scally, Heikki Krogerus,
Sakari Ailus, Saravana Kannan, Rob Herring, linux-acpi,
driver-core, linux-kernel, brgl, stable
On Mon, 11 May 2026 09:49:26 +0200, Bartosz Golaszewski wrote:
> [PATCH v2] device property: initialize the remaining fields of fwnode_handle in fwnode_init()
Applied, thanks!
Branch: driver-core-testing
Tree: git://git.kernel.org/pub/scm/linux/kernel/git/driver-core/driver-core.git
[1/1] device property: initialize the remaining fields of fwnode_handle in fwnode_init()
commit: 7eba000621ff
[ Fix typo in commit message. - Danilo ]
The patch will appear in the next linux-next integration (typically within 24
hours on weekdays).
The patch is in the driver-core-testing branch and will be promoted to
driver-core-next after validation.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-11 19:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-11 7:49 [PATCH v2] device property: initialize the remaining fields of fwnode_handle in fwnode_init() Bartosz Golaszewski
2026-05-11 19:58 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox