Skip to content

Commit

Permalink
virtio/virtio_mem: handle a possible NULL as a memcpy parameter
Browse files Browse the repository at this point in the history
There is a check for vm->sbm.sb_states before, and it should check
it here as well.

Signed-off-by: Peng Hao <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Michael S. Tsirkin <[email protected]>
Fixes: 5f1f79b ("virtio-mem: Paravirtualized memory hotplug")
Cc: [email protected] # v5.8+
  • Loading branch information
Peng Hao authored and mstsirkin committed Jan 14, 2022
1 parent 2b68224 commit cf4a449
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/virtio/virtio_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cf4a449

Please sign in to comment.