diff options
author | Andrew Goodbody <andrew.goodbody@linaro.org> | 2025-07-07 11:04:29 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-07-14 15:16:56 -0600 |
commit | cd79a2839b01571b6f2915c219f71c05e3c97482 (patch) | |
tree | d8e3695659c7c48f59f45907e66837526b0b8641 | |
parent | 5f70be08b015a5dc2296ea0073ecc8165fc48588 (diff) |
ofnode: NULL check bootscr_flash_size before dereference
Move the NULL check of bootscr_flash_size to before the first time it is
dereferenced to avoid any possible segment violations.
This issue found by Smatch.
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
-rw-r--r-- | drivers/core/ofnode.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 26e014d5c53..e040e3f2806 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1961,6 +1961,12 @@ int ofnode_read_bootscript_flash(u64 *bootscr_flash_offset, ofnode uboot; *bootscr_flash_offset = 0; + + if (!bootscr_flash_size) { + dm_warn("bootscr-flash-size is zero. Ignoring properties!\n"); + return -EINVAL; + } + *bootscr_flash_size = 0; uboot = ofnode_path("/options/u-boot"); @@ -1979,12 +1985,6 @@ int ofnode_read_bootscript_flash(u64 *bootscr_flash_offset, if (ret) return -EINVAL; - if (!bootscr_flash_size) { - dm_warn("bootscr-flash-size is zero. Ignoring properties!\n"); - *bootscr_flash_offset = 0; - return -EINVAL; - } - return 0; } |