Skip to content

Commit 215c90e

Browse files
brglgregkh
authored andcommitted
device property: set fwnode->secondary to NULL in fwnode_init()
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 <stable@kernel.org> Fixes: 01bb86b ("driver core: Add fwnode_init()") Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Reviewed-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> Link: https://patch.msgid.link/20260506115701.23035-1-bartosz.golaszewski@oss.qualcomm.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 237557b commit 215c90e

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

include/linux/fwnode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ struct fwnode_operations {
208208
static inline void fwnode_init(struct fwnode_handle *fwnode,
209209
const struct fwnode_operations *ops)
210210
{
211+
fwnode->secondary = NULL;
211212
fwnode->ops = ops;
212213
INIT_LIST_HEAD(&fwnode->consumers);
213214
INIT_LIST_HEAD(&fwnode->suppliers);

0 commit comments

Comments
 (0)