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

vhost: use kzalloc() instead of kmalloc() followed by memset()

Use kzalloc() to allocate new zeroed out msg node instead of
memsetting a node allocated with kmalloc().

Signed-off-by: Prathu Baronia <prathubaronia2011@gmail.com>
Message-Id: <20230522085019.42914-1-prathubaronia2011@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

authored by

Prathu Baronia and committed by
Michael S. Tsirkin
4d8df0f5 9561de3a

+2 -3
+2 -3
drivers/vhost/vhost.c
··· 2563 2563 /* Create a new message. */ 2564 2564 struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type) 2565 2565 { 2566 - struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL); 2566 + /* Make sure all padding within the structure is initialized. */ 2567 + struct vhost_msg_node *node = kzalloc(sizeof(*node), GFP_KERNEL); 2567 2568 if (!node) 2568 2569 return NULL; 2569 2570 2570 - /* Make sure all padding within the structure is initialized. */ 2571 - memset(&node->msg, 0, sizeof node->msg); 2572 2571 node->vq = vq; 2573 2572 node->msg.type = type; 2574 2573 return node;