* [PATCH 00/17] tty: small cleanups and fixes
@ 2023-11-21 9:22 Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send() Jiri Slaby (SUSE)
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-11-21 9:22 UTC (permalink / raw)
To: gregkh
Cc: linux-usb, linuxppc-dev, linux-alpha, Richard Henderson,
linux-kernel, Eric Dumazet, netdev, Ivan Kokshaysky, linux-serial,
Jan Kara, Jakub Kicinski, Matt Turner, Paolo Abeni,
Jiri Slaby (SUSE), David S. Miller, Laurentiu Tudor
This is a series to fix/clean up some obvious issues I revealed during
u8+size_t conversions (to be posted later).
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Jan Kara <jack@suse.com>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: linux-alpha@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-usb@vger.kernel.org
Cc: Matt Turner <mattst88@gmail.com>
Cc: netdev@vger.kernel.org
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Jiri Slaby (SUSE) (17):
tty: deprecate tty_write_message()
tty: remove unneeded mbz from tiocsti()
tty: fix tty_operations types in documentation
tty: move locking docs out of Returns for functions in tty.h
tty: amiserial: return from receive_chars() without goto
tty: amiserial: use bool and rename overrun flag in receive_chars()
tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send()
tty: goldfish: drop unneeded temporary variables
tty: hso: don't emit load/unload info to the log
tty: hso: don't initialize global serial_table
tty: hvc_console: use flexible array for outbuf
tty: nozomi: remove unused debugging DUMP()
tty: srmcons: use 'buf' directly in srmcons_do_write()
tty: srmcons: use 'count' directly in srmcons_do_write()
tty: srmcons: make srmcons_do_write() return void
tty: srmcons: switch need_cr to bool
tty: srmcons: make 'str_cr' const and non-array
arch/alpha/kernel/srmcons.c | 29 +++++++++++++----------------
drivers/net/usb/hso.c | 11 -----------
drivers/tty/amiserial.c | 10 ++++------
drivers/tty/ehv_bytechan.c | 7 +++++--
drivers/tty/goldfish.c | 7 ++-----
drivers/tty/hvc/hvc_console.c | 4 +---
drivers/tty/hvc/hvc_console.h | 2 +-
drivers/tty/nozomi.c | 18 ------------------
drivers/tty/tty_io.c | 8 ++++++--
include/linux/tty.h | 12 +++++++-----
include/linux/tty_driver.h | 5 ++---
11 files changed, 41 insertions(+), 72 deletions(-)
--
2.42.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send()
2023-11-21 9:22 [PATCH 00/17] tty: small cleanups and fixes Jiri Slaby (SUSE)
@ 2023-11-21 9:22 ` Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 11/17] tty: hvc_console: use flexible array for outbuf Jiri Slaby (SUSE)
2023-11-23 20:19 ` [PATCH 00/17] tty: small cleanups and fixes Greg KH
2 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-11-21 9:22 UTC (permalink / raw)
To: gregkh
Cc: linuxppc-dev, Jiri Slaby (SUSE), linux-kernel, linux-serial,
Laurentiu Tudor
There is a helper for memcpy(buffer)+memset(the_rest). Use it for
simplicity.
And add a comment why we are doing the copy in the first place.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
Cc: linuxppc-dev@lists.ozlabs.org
---
drivers/tty/ehv_bytechan.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index a067628e01c8..cc9f4338da60 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -143,9 +143,12 @@ static unsigned int local_ev_byte_channel_send(unsigned int handle,
char buffer[EV_BYTE_CHANNEL_MAX_BYTES];
unsigned int c = *count;
+ /*
+ * ev_byte_channel_send() expects at least EV_BYTE_CHANNEL_MAX_BYTES
+ * (16 B) in the buffer. Fake it using a local buffer if needed.
+ */
if (c < sizeof(buffer)) {
- memcpy(buffer, p, c);
- memset(&buffer[c], 0, sizeof(buffer) - c);
+ memcpy_and_pad(buffer, sizeof(buffer), p, c, 0);
p = buffer;
}
return ev_byte_channel_send(handle, count, p);
--
2.42.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 11/17] tty: hvc_console: use flexible array for outbuf
2023-11-21 9:22 [PATCH 00/17] tty: small cleanups and fixes Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send() Jiri Slaby (SUSE)
@ 2023-11-21 9:22 ` Jiri Slaby (SUSE)
2023-11-23 20:19 ` [PATCH 00/17] tty: small cleanups and fixes Greg KH
2 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby (SUSE) @ 2023-11-21 9:22 UTC (permalink / raw)
To: gregkh; +Cc: linuxppc-dev, Jiri Slaby (SUSE), linux-kernel, linux-serial
This means:
* move outbuf to the end of struct hvc_struct and convert from pointer
to flexible array (the structure is smaller now)
* use struct_size() at the allocation site
* align outbuf in the struct instead of ALIGN() at kzalloc()
And apart from the above, use u8 instead of char (which are the same
thanks to -funsigned-char). The former is now preferred over the latter.
It makes the code easier to understand.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: linuxppc-dev@lists.ozlabs.org
---
drivers/tty/hvc/hvc_console.c | 4 +---
drivers/tty/hvc/hvc_console.h | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
index 959fae54ca39..93b613e1f176 100644
--- a/drivers/tty/hvc/hvc_console.c
+++ b/drivers/tty/hvc/hvc_console.c
@@ -922,8 +922,7 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
return ERR_PTR(err);
}
- hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size,
- GFP_KERNEL);
+ hp = kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL);
if (!hp)
return ERR_PTR(-ENOMEM);
@@ -931,7 +930,6 @@ struct hvc_struct *hvc_alloc(uint32_t vtermno, int data,
hp->data = data;
hp->ops = ops;
hp->outbuf_size = outbuf_size;
- hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))];
tty_port_init(&hp->port);
hp->port.ops = &hvc_port_ops;
diff --git a/drivers/tty/hvc/hvc_console.h b/drivers/tty/hvc/hvc_console.h
index 9668f821db01..b718714bf399 100644
--- a/drivers/tty/hvc/hvc_console.h
+++ b/drivers/tty/hvc/hvc_console.h
@@ -37,7 +37,6 @@ struct hvc_struct {
spinlock_t lock;
int index;
int do_wakeup;
- char *outbuf;
int outbuf_size;
int n_outbuf;
uint32_t vtermno;
@@ -48,6 +47,7 @@ struct hvc_struct {
struct work_struct tty_resize;
struct list_head next;
unsigned long flags;
+ u8 outbuf[] __aligned(sizeof(long));
};
/* implemented by a low level driver */
--
2.42.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 00/17] tty: small cleanups and fixes
2023-11-21 9:22 [PATCH 00/17] tty: small cleanups and fixes Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send() Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 11/17] tty: hvc_console: use flexible array for outbuf Jiri Slaby (SUSE)
@ 2023-11-23 20:19 ` Greg KH
2023-11-27 9:30 ` Jiri Slaby
2 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2023-11-23 20:19 UTC (permalink / raw)
To: Jiri Slaby (SUSE)
Cc: linux-usb, netdev, linux-alpha, Richard Henderson, linux-kernel,
Eric Dumazet, Ivan Kokshaysky, linux-serial, Jan Kara,
Jakub Kicinski, Matt Turner, Paolo Abeni, linuxppc-dev,
David S. Miller, Laurentiu Tudor
On Tue, Nov 21, 2023 at 10:22:41AM +0100, Jiri Slaby (SUSE) wrote:
> This is a series to fix/clean up some obvious issues I revealed during
> u8+size_t conversions (to be posted later).
I applied most of these except the last few, as I think you were going
to reorder them, right?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 00/17] tty: small cleanups and fixes
2023-11-23 20:19 ` [PATCH 00/17] tty: small cleanups and fixes Greg KH
@ 2023-11-27 9:30 ` Jiri Slaby
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Slaby @ 2023-11-27 9:30 UTC (permalink / raw)
To: Greg KH
Cc: linux-usb, netdev, linux-alpha, Richard Henderson, linux-kernel,
Eric Dumazet, Ivan Kokshaysky, linux-serial, Jan Kara,
Jakub Kicinski, Matt Turner, Paolo Abeni, linuxppc-dev,
David S. Miller, Laurentiu Tudor
On 23. 11. 23, 21:19, Greg KH wrote:
> On Tue, Nov 21, 2023 at 10:22:41AM +0100, Jiri Slaby (SUSE) wrote:
>> This is a series to fix/clean up some obvious issues I revealed during
>> u8+size_t conversions (to be posted later).
>
> I applied most of these except the last few, as I think you were going
> to reorder them, right?
Yes, great. I will rebase and see/resend what is missing.
thanks,
--
js
suse labs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-27 9:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-21 9:22 [PATCH 00/17] tty: small cleanups and fixes Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 07/17] tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send() Jiri Slaby (SUSE)
2023-11-21 9:22 ` [PATCH 11/17] tty: hvc_console: use flexible array for outbuf Jiri Slaby (SUSE)
2023-11-23 20:19 ` [PATCH 00/17] tty: small cleanups and fixes Greg KH
2023-11-27 9:30 ` Jiri Slaby
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).