serdev: fix receive_buf return value when no callback
authorJohan Hovold <johan@kernel.org>
Fri, 3 Nov 2017 14:30:53 +0000 (15:30 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Feb 2018 10:07:53 +0000 (11:07 +0100)
commit2ba11e4309b58d290d471f24b2f89d481e4d873f
tree71d599de8f6409158cf84c170c44027d0c6053c5
parent371cf4043b29e55cfa30c68e7304659e6e253222
serdev: fix receive_buf return value when no callback

[ Upstream commit fd00cf81a9a84776ba58e56bd042c726dcf75cf3 ]

The receive_buf callback is supposed to return the number of bytes
processed and should specifically not return a negative errno.

Due to missing sanity checks in the serdev tty-port controller, a driver
not providing a receive_buf callback could cause the flush_to_ldisc()
worker to spin in a tight loop when the tty buffer pointers are
incremented with -EINVAL (-22).

The missing sanity checks have now been added to the tty-port
controller, but let's fix up the serdev-controller helper as well.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/serdev.h