virtio-balloon: kzalloc the vb struct
authorWei Wang <wei.w.wang@intel.com>
Thu, 16 Aug 2018 07:50:57 +0000 (15:50 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 21 Aug 2018 21:56:24 +0000 (00:56 +0300)
Zero all the vb fields at alloaction, so that we don't need to
zero-initialize each field one by one later.

Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/virtio/virtio_balloon.c

index 8100e77b1b0bb590f032b64db04de529539b0763..d97d73c73303a659005b4afe18fe30a7ed11aa6f 100644 (file)
@@ -561,7 +561,7 @@ static int virtballoon_probe(struct virtio_device *vdev)
                return -EINVAL;
        }
 
-       vdev->priv = vb = kmalloc(sizeof(*vb), GFP_KERNEL);
+       vdev->priv = vb = kzalloc(sizeof(*vb), GFP_KERNEL);
        if (!vb) {
                err = -ENOMEM;
                goto out;
@@ -570,8 +570,6 @@ static int virtballoon_probe(struct virtio_device *vdev)
        INIT_WORK(&vb->update_balloon_stats_work, update_balloon_stats_func);
        INIT_WORK(&vb->update_balloon_size_work, update_balloon_size_func);
        spin_lock_init(&vb->stop_update_lock);
-       vb->stop_update = false;
-       vb->num_pages = 0;
        mutex_init(&vb->balloon_lock);
        init_waitqueue_head(&vb->acked);
        vb->vdev = vdev;
@@ -602,7 +600,6 @@ static int virtballoon_probe(struct virtio_device *vdev)
                err = PTR_ERR(vb->vb_dev_info.inode);
                kern_unmount(balloon_mnt);
                unregister_oom_notifier(&vb->nb);
-               vb->vb_dev_info.inode = NULL;
                goto out_del_vqs;
        }
        vb->vb_dev_info.inode->i_mapping->a_ops = &balloon_aops;