Currently, member `sentinel` in `struct tty_bufhead` is causing trouble
becase its type is `struct tty_buffer`, which is a flexible structure
--meaning it contains a flexible-array member. This combined with the
fact that `sentinel` is positioned in the middle of `struct tty_bufhead`,
Suggested-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>
---
Changes in v3:
- Implement `struct tty_buffer_hdr` as a separate struct and embed it
into `struct tty_buffer`. Refactor the rest of the code, accordingly.
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 79f0ff94ce00..cd04a6567a33 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -576,11 +579,14 @@ int tty_insert_flip_string_and_push_buffer(struct tty_port *port,
void tty_buffer_init(struct tty_port *port)
{
struct tty_bufhead *buf = &port->buf;
+ struct tty_buffer *buf_sentinel;
+
+ buf_sentinel = container_of(&buf->sentinel, struct tty_buffer, hdr);
--- a/include/linux/tty_buffer.h
+++ b/include/linux/tty_buffer.h
@@ -7,7 +7,7 @@
#include <linux/mutex.h>
#include <linux/workqueue.h>
-struct tty_buffer {
+struct tty_buffer_hdr {
union {
struct tty_buffer *next;
struct llist_node free;
@@ -15,9 +15,13 @@ struct tty_buffer {
unsigned int used;
unsigned int size;
unsigned int commit;
- unsigned int lookahead; /* Lazy update on recv, can become less than "read" */
+ unsigned int lookahead; /* Lazy update on recv, can become less than "read" */