linux-stable/drivers/char
Laurent Vivier 67380639df virtio_console: allocate inbufs in add_port() only if it is needed
commit d791cfcbf9 upstream.

When we hot unplug a virtserialport and then try to hot plug again,
it fails:

(qemu) chardev-add socket,id=serial0,path=/tmp/serial0,server,nowait
(qemu) device_add virtserialport,bus=virtio-serial0.0,nr=2,\
                  chardev=serial0,id=serial0,name=serial0
(qemu) device_del serial0
(qemu) device_add virtserialport,bus=virtio-serial0.0,nr=2,\
                  chardev=serial0,id=serial0,name=serial0
kernel error:
  virtio-ports vport2p2: Error allocating inbufs
qemu error:
  virtio-serial-bus: Guest failure in adding port 2 for device \
                     virtio-serial0.0

This happens because buffers for the in_vq are allocated when the port is
added but are not released when the port is unplugged.

They are only released when virtconsole is removed (see a7a69ec0d8)

To avoid the problem and to be symmetric, we could allocate all the buffers
in init_vqs() as they are released in remove_vqs(), but it sounds like
a waste of memory.

Rather than that, this patch changes add_port() logic to ignore ENOSPC
error in fill_queue(), which means queue has already been filled.

Fixes: a7a69ec0d8 ("virtio_console: free buffers after reset")
Cc: mst@redhat.com
Cc: stable@vger.kernel.org
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-12-01 09:16:10 +01:00
..
agp char: amd64-agp: Use 64-bit arithmetic instead of 32-bit 2018-07-10 13:50:31 +10:00
hw_random hwrng: core - don't wait on add_early_randomness() 2019-10-05 13:10:12 +02:00
ipmi ipmi: fix return value of ipmi_set_my_LUN 2019-11-20 18:46:56 +01:00
mwave char/mwave: fix potential Spectre v1 vulnerability 2019-01-31 08:14:36 +01:00
pcmcia char: pcmcia: remove redundant pointer dev 2018-07-03 13:01:57 +02:00
tpm tpm: Fix TPM 1.2 Shutdown sequence to prevent future TPM operations 2019-10-07 18:56:28 +02:00
xilinx_hwicap
xillybus PCI: Add Altera vendor ID 2018-03-14 19:13:47 +01:00
adi.c char: sparc64: Add privileged ADI driver 2018-06-05 11:24:55 -07:00
apm-emulation.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
applicom.c applicom: Fix potential Spectre v1 vulnerabilities 2019-03-10 07:17:20 +01:00
applicom.h
bsr.c
ds1620.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
dsp56k.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
dtlk.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
efirtc.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
generic_nvram.c
hangcheck-timer.c
hpet.c hpet: Fix division by zero in hpet_time_div() 2019-07-31 07:27:10 +02:00
Kconfig tty: mark Siemens R3964 line discipline as BROKEN 2019-04-17 08:38:47 +02:00
lp.c char: lp: use true or false for boolean values 2018-01-25 10:56:02 +01:00
Makefile char: sparc64: Add privileged ADI driver 2018-06-05 11:24:55 -07:00
mbcs.c
mbcs.h
mem.c /dev/mem: Bail out upon SIGKILL. 2019-10-05 13:10:11 +02:00
misc.c proc: introduce proc_create_seq{,_data} 2018-05-16 07:23:35 +02:00
mspec.c char: mspec: change return type to vm_fault_t 2018-04-23 13:51:53 +02:00
nsc_gpio.c
nvram.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
nwbutton.c
nwbutton.h
nwflash.c
pc8736x_gpio.c
powernv-op-panel.c
ppdev.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
ps3flash.c
random.c crypto: chacha20 - Fix chacha20_block() keystream alignment (again) 2019-11-20 18:47:11 +01:00
raw.c treewide: Use array_size() in vzalloc() 2018-06-12 16:19:22 -07:00
rtc.c char: rtc: remove task handling 2018-08-02 17:16:03 +02:00
scx200_gpio.c
snsc.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
snsc.h
snsc_event.c
sonypi.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
tb0219.c
tlclk.c
toshiba.c proc: introduce proc_create_single{,_data} 2018-05-16 07:23:35 +02:00
ttyprintk.c
uv_mmtimer.c
virtio_console.c virtio_console: allocate inbufs in add_port() only if it is needed 2019-12-01 09:16:10 +01:00