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

virtio/virtio_mem: handle a possible NULL as a memcpy parameter

There is a check for vm->sbm.sb_states before, and it should check
it here as well.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
Link: https://lore.kernel.org/r/20211222011225.40573-1-flyingpeng@tencent.com
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Fixes: 5f1f79bbc9e2 ("virtio-mem: Paravirtualized memory hotplug")
Cc: stable@vger.kernel.org # v5.8+

authored by

Peng Hao and committed by
Michael S. Tsirkin
cf4a4493 2b68224e

+1 -1
+1 -1
drivers/virtio/virtio_mem.c
··· 593 593 return -ENOMEM; 594 594 595 595 mutex_lock(&vm->hotplug_mutex); 596 - if (new_bitmap) 596 + if (vm->sbm.sb_states) 597 597 memcpy(new_bitmap, vm->sbm.sb_states, old_pages * PAGE_SIZE); 598 598 599 599 old_bitmap = vm->sbm.sb_states;