Skip to content

Commit 4d8df0f

Browse files
praton1729mstsirkin
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]> Reviewed-by: Stefano Garzarella <[email protected]>
1 parent 9561de3 commit 4d8df0f

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

drivers/vhost/vhost.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,12 +2563,11 @@ EXPORT_SYMBOL_GPL(vhost_disable_notify);
25632563
/* Create a new message. */
25642564
struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type)
25652565
{
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);
25672568
if (!node)
25682569
return NULL;
25692570

2570-
/* Make sure all padding within the structure is initialized. */
2571-
memset(&node->msg, 0, sizeof node->msg);
25722571
node->vq = vq;
25732572
node->msg.type = type;
25742573
return node;

0 commit comments

Comments
 (0)