Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serdev: fix receive_buf return value when no callback

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>

authored by

Johan Hovold and committed by
Greg Kroah-Hartman
fd00cf81 eb281683

+1 -1
+1 -1
include/linux/serdev.h
··· 184 184 struct serdev_device *serdev = ctrl->serdev; 185 185 186 186 if (!serdev || !serdev->ops->receive_buf) 187 - return -EINVAL; 187 + return 0; 188 188 189 189 return serdev->ops->receive_buf(serdev, data, count); 190 190 }