Commit 4af9ed57 authored by Andrzej Hajda's avatar Andrzej Hajda Committed by Matt Fleming

efi: Fix handling error value in fdt_find_uefi_params

of_get_flat_dt_subnode_by_name can return negative value in case of error.
Assigning the result to unsigned variable and checking if the variable
is lesser than zero is incorrect and always false.
The patch fixes it by using signed variable to check the result.

The problem has been detected using semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
Signed-off-by: default avatarAndrzej Hajda <a.hajda@samsung.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Shawn Lin <shawn.lin@rock-chips.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarMatt Fleming <matt@codeblueprint.co.uk>
parent d4c4fed0
...@@ -657,9 +657,12 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, ...@@ -657,9 +657,12 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
} }
if (subnode) { if (subnode) {
node = of_get_flat_dt_subnode_by_name(node, subnode); int err = of_get_flat_dt_subnode_by_name(node, subnode);
if (node < 0)
if (err < 0)
return 0; return 0;
node = err;
} }
return __find_uefi_params(node, info, dt_params[i].params); return __find_uefi_params(node, info, dt_params[i].params);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment