Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1729951
| From | Geert Uytterhoeven <geert@linux-m68k.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() |
| Date | 2017-09-10 12:30 +0200 |
| Message-ID | <uo7F0-2kK-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
With gcc 4.1.2:
drivers/of/overlay.c: In function ‘dup_and_fixup_symbol_prop’:
drivers/of/overlay.c:108: warning: ‘overlay_name_len’ may be used uninitialized in this function
drivers/of/overlay.c:100: warning: ‘ovinfo’ may be used uninitialized in this function
Indeed, if ov->count == 0, both variables are uninitialized, which may
lead to a crash when dereferencing ovinfo later.
Currently this is a false positive, as the sole creator of of_overlay
structures (of_build_overlay_info(), introduced in commit
7518b5890d8ac366 ("of/overlay: Introduce DT overlay support") checks for
this.
To prevent future issues, add a check for a zero ov->count to
dup_and_fixup_symbol_prop(). Note that this does not get rid of the
actual compiler warning.
Fixes: d1651b03c2df75db ("of: overlay: add overlay symbols to live device tree")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/of/overlay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 8ecfee31ab6d3874..ebe19e0f8e4d1f4b 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -108,7 +108,7 @@ static struct property *dup_and_fixup_symbol_prop(struct of_overlay *ov,
int overlay_name_len;
int target_path_len;
- if (!prop->value)
+ if (!ov->count || !prop->value)
return NULL;
symbol_path = prop->value;
--
2.7.4
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-10 12:30 +0200
Re: [PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() Rob Herring <robh@kernel.org> - 2017-09-19 19:30 +0200
Re: [PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() Frank Rowand <frowand.list@gmail.com> - 2017-09-19 20:30 +0200
Re: [PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() Rob Herring <robh+dt@kernel.org> - 2017-09-19 21:20 +0200
Re: [PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-09-19 22:20 +0200
Re: [PATCH] of: overlay: Fix uninitialized vars in dup_and_fixup_symbol_prop() Frank Rowand <frowand.list@gmail.com> - 2017-09-20 02:30 +0200
csiph-web