diff mbox series

[kvmtool,4/4] virtio/rng: Zero-initialize the device

Message ID 20220722141731.64039-5-jean-philippe@linaro.org (mailing list archive)
State New, archived
Headers show
Series Makefile and virtio fixes | expand

Commit Message

Jean-Philippe Brucker July 22, 2022, 2:17 p.m. UTC
Use calloc() to avoid uninitialized fields in the rng device.

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 virtio/rng.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/virtio/rng.c b/virtio/rng.c
index f9d607f6..63ab8fce 100644
--- a/virtio/rng.c
+++ b/virtio/rng.c
@@ -162,7 +162,7 @@  int virtio_rng__init(struct kvm *kvm)
 	if (!kvm->cfg.virtio_rng)
 		return 0;
 
-	rdev = malloc(sizeof(*rdev));
+	rdev = calloc(1, sizeof(*rdev));
 	if (rdev == NULL)
 		return -ENOMEM;