diff options
author | Jiri Slaby (SUSE) <jirislaby@kernel.org> | 2023-11-21 12:22:48 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-11-25 10:23:17 +0300 |
commit | 9d3e3301ae9958809b4d96787eaf76221c704ed6 (patch) | |
tree | 67e098eaa82ab70e51bb418ca3882454334e2433 /drivers/tty/ehv_bytechan.c | |
parent | 73b2ed3675697f1b20d5fa3408397c65a2cbc13e (diff) | |
download | linux-9d3e3301ae9958809b4d96787eaf76221c704ed6.tar.xz |
tty: ehv_bytecha: use memcpy_and_pad() in local_ev_byte_channel_send()
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
Link: https://lore.kernel.org/r/20231121092258.9334-8-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/ehv_bytechan.c')
-rw-r--r-- | drivers/tty/ehv_bytechan.c | 7 |
1 files 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); |