summaryrefslogtreecommitdiff
path: root/drivers/virtio
diff options
context:
space:
mode:
authorPeng Hao <flyingpenghao@gmail.com>2021-12-22 04:12:25 +0300
committerMichael S. Tsirkin <mst@redhat.com>2022-01-15 02:50:53 +0300
commitcf4a4493ff70874f8af26d75d4346c591c298e89 (patch)
tree7e944aeaf81849d94d637ee6decba4b528b781ff /drivers/virtio
parent2b68224ec61bb66aa2a24ad099b6af65138fa888 (diff)
downloadlinux-cf4a4493ff70874f8af26d75d4346c591c298e89.tar.xz
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+
Diffstat (limited to 'drivers/virtio')
-rw-r--r--drivers/virtio/virtio_mem.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/virtio/virtio_mem.c b/drivers/virtio/virtio_mem.c
index a6a78685cfbe..38becd8d578c 100644
--- a/drivers/virtio/virtio_mem.c
+++ b/drivers/virtio/virtio_mem.c
@@ -593,7 +593,7 @@ static int virtio_mem_sbm_sb_states_prepare_next_mb(struct virtio_mem *vm)
return -ENOMEM;
mutex_lock(&vm->hotplug_mutex);
- if (new_bitmap)
+ if (vm->sbm.sb_states)
memcpy(new_bitmap, vm->sbm.sb_states, old_pages * PAGE_SIZE);
old_bitmap = vm->sbm.sb_states;