CC: [email protected]
CC: [email protected]
CC: Robert Hu <[email protected]>
CC: Farrah Chen <[email protected]>
CC: Danmei Wei <[email protected]>
TO: Peter Xu <[email protected]>
CC: Paolo Bonzini <[email protected]>
CC: Lei Cao <[email protected]>
CC: [email protected]
CC: [email protected]

From: kernel test robot <[email protected]>

virt/kvm/dirty_ring.c:70:20-27: WARNING: vzalloc should be used for ring -> 
dirty_gfns, instead of vmalloc/memset


 Use zeroing allocator rather than allocator followed by memset with 0

 This considers some simple cases that are common and easy to validate
 Note in particular that there are no ...s in the rule, so all of the
 matched code has to be contiguous

Generated by: scripts/coccinelle/api/alloc/zalloc-simple.cocci

Fixes: fb04a1eddb1a ("KVM: X86: Implement ring-based dirty memory tracking")
CC: Peter Xu <[email protected]>
Reported-by: kernel test robot <[email protected]>
Signed-off-by: kernel test robot <[email protected]>
---

tree:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git queue
head:   0a59d24b139a98ad0a2d778205fca6619014633f
commit: fb04a1eddb1a65b6588a021bdc132270d5ae48bb [24/39] KVM: X86: Implement 
ring-based dirty memory tracking
:::::: branch date: 8 hours ago
:::::: commit date: 8 hours ago

Please take the patch only if it's a positive warning. Thanks!

 dirty_ring.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

--- a/virt/kvm/dirty_ring.c
+++ b/virt/kvm/dirty_ring.c
@@ -67,10 +67,9 @@ static void kvm_reset_dirty_gfn(struct k
 
 int kvm_dirty_ring_alloc(struct kvm_dirty_ring *ring, int index, u32 size)
 {
-       ring->dirty_gfns = vmalloc(size);
+       ring->dirty_gfns = vzalloc(size);
        if (!ring->dirty_gfns)
                return -ENOMEM;
-       memset(ring->dirty_gfns, 0, size);
 
        ring->size = size / sizeof(struct kvm_dirty_gfn);
        ring->soft_limit = ring->size - kvm_dirty_ring_get_rsvd_entries();
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to