tty: n_gsm: fix invalid gsmtty_write_room() result
authorDaniel Starke <daniel.starke@siemens.com>
Wed, 4 May 2022 08:17:33 +0000 (10:17 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 May 2022 21:00:07 +0000 (23:00 +0200)
commit9361ebfbb79fd1bc8594a487c01ad52cdaa391ea
tree849430a283636e36abaa05a1d21c8afa058079a6
parentedd5f60c340086891fab094ad61270d6c80f9ca4
tty: n_gsm: fix invalid gsmtty_write_room() result

gsmtty_write() does not prevent the user to use the full fifo size of 4096
bytes as allocated in gsm_dlci_alloc(). However, gsmtty_write_room() tries
to limit the return value by 'TX_SIZE' and returns a negative value if the
fifo has more than 'TX_SIZE' bytes stored. This is obviously wrong as
'TX_SIZE' is defined as 512.
Define 'TX_SIZE' to the fifo size and use it accordingly for allocation to
keep the current behavior. Return the correct remaining size of the fifo in
gsmtty_write_room() via kfifo_avail().

Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
Link: https://lore.kernel.org/r/20220504081733.3494-3-daniel.starke@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c