summaryrefslogtreecommitdiff
path: root/include/linux/serial_core.h
diff options
context:
space:
mode:
authorDouglas Anderson <dianders@chromium.org>2018-03-23 20:58:31 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-04-23 13:31:13 +0300
commitc1c734cb1f54b062f7e67ffc9656d82f5b412b9c (patch)
treece4b144a9cf2d24005dfd1a8e3c1ae9b466adb5e /include/linux/serial_core.h
parent4405898da936a710d200b2f826ca0f2e68c59f83 (diff)
downloadlinux-c1c734cb1f54b062f7e67ffc9656d82f5b412b9c.tar.xz
serial: core: Make sure compiler barfs for 16-byte earlycon names
As part of bringup I ended up wanting to call an earlycon driver by a name that was exactly 16-bytes big, specifically "qcom_geni_serial". Unfortunately, when I tried this I found that things compiled just fine. They just didn't work. Specifically the compiler felt perfectly justified in initting the ".name" field of "struct earlycon_id" with the full 16-bytes and just skipping the '\0'. Needless to say, that behavior didn't seem ideal, but I guess someone must have allowed it for a reason. One way to fix this is to shorten the name field to 15 bytes and then add an extra byte after that nobody touches. This should always be initted to 0 and we're golden. There are, of course, other ways to fix this too. We could audit all the users of the "name" field and make them stop at both null termination or at 16 bytes. We could also just make the name field much bigger so that we're not likely to run into this. ...but both seem like we'll just hit the bug again. Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/serial_core.h')
-rw-r--r--include/linux/serial_core.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index d224961e1346..d2a2e4bc2435 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -349,7 +349,8 @@ struct earlycon_device {
};
struct earlycon_id {
- char name[16];
+ char name[15];
+ char name_term; /* In case compiler didn't '\0' term name */
char compatible[128];
int (*setup)(struct earlycon_device *, const char *options);
} __aligned(32);