From 9f528374bffb5868ec6bf896f57919a709b31911 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Wed, 21 Apr 2021 09:37:49 +0800 Subject: [PATCH] net/virtio: fix getline memory leakage This patch fixes getline memory leakage when parsing dynamic major num. Fixes: 7d62bf6f54ba ("net/virtio: introduce vhost-vDPA backend type") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) Reviewed-by: Chenbo Xia --- drivers/net/virtio/virtio_user_ethdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 79bd31ed82..e85906e9eb 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -360,7 +360,7 @@ vdpa_dynamic_major_num(void) { FILE *fp; char *line = NULL; - size_t size; + size_t size = 0; char name[11]; bool found = false; uint32_t num; @@ -380,6 +380,7 @@ vdpa_dynamic_major_num(void) break; } } + free(line); fclose(fp); return found ? num : UNNAMED_MAJOR; } -- 2.20.1