]> code.ossystems Code Review - openembedded-core.git/commitdiff
dtc: Fix array-bounds error
authorKhem Raj <raj.khem@gmail.com>
Sat, 27 Feb 2021 07:41:31 +0000 (23:41 -0800)
committerSteve Sakoman <steve@sakoman.com>
Thu, 11 Mar 2021 15:00:02 +0000 (05:00 -1000)
Fixes
| libfdt/libfdt.h:251:28: error: array subscript 'struct fdt_header[0]' is partly outside array bounds of 'unsigned char[4]' [-Werror=array-bounds]
|   251 |                 fdth->name = cpu_to_fdt32(val); \
|       |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit cd4fe4ec658ce4861fc970149f78b0ca7fda8fe0)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/recipes-kernel/dtc/dtc/0001-fdtdump-Fix-gcc11-warning.patch [new file with mode: 0644]
meta/recipes-kernel/dtc/dtc_1.6.0.bb

diff --git a/meta/recipes-kernel/dtc/dtc/0001-fdtdump-Fix-gcc11-warning.patch b/meta/recipes-kernel/dtc/dtc/0001-fdtdump-Fix-gcc11-warning.patch
new file mode 100644 (file)
index 0000000..ec825cb
--- /dev/null
@@ -0,0 +1,35 @@
+From 4827e0db6c4f7dea7f4094f49d3bb48ef6dfdc2d Mon Sep 17 00:00:00 2001
+From: David Gibson <david@gibson.dropbear.id.au>
+Date: Wed, 6 Jan 2021 14:52:26 +1100
+Subject: [PATCH] fdtdump: Fix gcc11 warning
+
+In one place, fdtdump abuses fdt_set_magic(), passing it just a small char
+array instead of the full fdt header it expects.  That's relying on the
+fact that in fact fdt_set_magic() will only actually access the first 4
+bytes of the buffer.
+
+This trips a new warning in GCC 11 - and it's entirely possible it was
+always UB.  So, don't do that.
+
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/utils/dtc/dtc.git/patch/?id=ca16a723fa9dde9c5da80dba567f48715000e77c]
+Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
+---
+ fdtdump.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/fdtdump.c b/fdtdump.c
+index 9613bef..d9fb374 100644
+--- a/fdtdump.c
++++ b/fdtdump.c
+@@ -217,7 +217,7 @@ int main(int argc, char *argv[])
+               char *p = buf;
+               char *endp = buf + len;
+-              fdt_set_magic(smagic, FDT_MAGIC);
++              fdt32_st(smagic, FDT_MAGIC);
+               /* poor man's memmem */
+               while ((endp - p) >= FDT_MAGIC_SIZE) {
+-- 
+2.30.1
+
index 92df70d9fcf8b431c6452157b0823317d7489d67..a4071378590134031088944223db20e6a64c6ea8 100644 (file)
@@ -5,6 +5,8 @@ LIC_FILES_CHKSUM = "file://GPL;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
 
 SRCREV = "2525da3dba9beceb96651dc2986581871dbeca30"
 
+SRC_URI += "file://0001-fdtdump-Fix-gcc11-warning.patch"
+
 S = "${WORKDIR}/git"
 
 BBCLASSEXTEND = "native nativesdk"