Skip to content

Commit f0b4e1c

Browse files
brglgregkh
authored andcommitted
device property: initialize the remaining fields of fwnode_handle in fwnode_init()
[ Upstream commit 7eba000 ] 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 uninitialized 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: 01bb86b ("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> Link: https://patch.msgid.link/20260511074927.9473-1-bartosz.golaszewski@oss.qualcomm.com [ Fix typo in commit message. - Danilo ] Signed-off-by: Danilo Krummrich <dakr@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent e54c05e commit f0b4e1c

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

include/linux/fwnode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,10 @@ static inline void fwnode_init(struct fwnode_handle *fwnode,
195195
{
196196
fwnode->secondary = NULL;
197197
fwnode->ops = ops;
198+
fwnode->dev = NULL;
198199
INIT_LIST_HEAD(&fwnode->consumers);
199200
INIT_LIST_HEAD(&fwnode->suppliers);
201+
fwnode->flags = 0;
200202
}
201203

202204
static inline void fwnode_set_flag(struct fwnode_handle *fwnode,

0 commit comments

Comments
 (0)