mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-10 12:57:06 +09:00
UPSTREAM: of: Make of_fwnode_handle() safer
On the expense of a little bit more complexity in the of_fwnode_handle()
macro, make the macro result in NULL in case its argument is NULL while
still referencing it only once.
BUG=b:64133998
TEST=Run on DT system with GPIO LEDs
Change-Id: I190e536298a7a04e4d4182722b27fd36725c4805
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
(cherry picked from commit debd3a3b27)
Reviewed-on: https://chromium-review.googlesource.com/766070
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Signed-off-by: Jacob Chen <jacob2.chen@rock-chips.com>
This commit is contained in:
@@ -144,7 +144,13 @@ static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
|
||||
container_of(fwnode, struct device_node, fwnode) : NULL;
|
||||
}
|
||||
|
||||
#define of_fwnode_handle(node) (&(node)->fwnode)
|
||||
#define of_fwnode_handle(node) \
|
||||
({ \
|
||||
typeof(node) __of_fwnode_handle_node = (node); \
|
||||
\
|
||||
__of_fwnode_handle_node ? \
|
||||
&__of_fwnode_handle_node->fwnode : NULL; \
|
||||
})
|
||||
|
||||
static inline bool of_have_populated_dt(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user