All of lore.kernel.org
 help / color / mirror / Atom feed
* [tip:efi/urgent] efi: Fix handling error value in fdt_find_uefi_params
@ 2016-09-05 15:19 tip-bot for Andrzej Hajda
  0 siblings, 0 replies; only message in thread
From: tip-bot for Andrzej Hajda @ 2016-09-05 15:19 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, stable, m.szyprowski, b.zolnierkie, hpa, shawn.lin, matt,
	a.hajda, mark.rutland, tglx

Commit-ID:  4af9ed578a50cd331a725322cfd9d555251ce788
Gitweb:     http://git.kernel.org/tip/4af9ed578a50cd331a725322cfd9d555251ce788
Author:     Andrzej Hajda <a.hajda@samsung.com>
AuthorDate: Tue, 30 Aug 2016 12:41:37 +0200
Committer:  Matt Fleming <matt@codeblueprint.co.uk>
CommitDate: Mon, 5 Sep 2016 11:26:42 +0100

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: Andrzej 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: Matt Fleming <matt@codeblueprint.co.uk>
---
 drivers/firmware/efi/efi.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 5a2631a..7dd2e2d 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -657,9 +657,12 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname,
 		}
 
 		if (subnode) {
-			node = of_get_flat_dt_subnode_by_name(node, subnode);
-			if (node < 0)
+			int err = of_get_flat_dt_subnode_by_name(node, subnode);
+
+			if (err < 0)
 				return 0;
+
+			node = err;
 		}
 
 		return __find_uefi_params(node, info, dt_params[i].params);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-09-05 15:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05 15:19 [tip:efi/urgent] efi: Fix handling error value in fdt_find_uefi_params tip-bot for Andrzej Hajda

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.