net/virtio: fix getline memory leakage
authorChengwen Feng <fengchengwen@huawei.com>
Wed, 21 Apr 2021 01:37:49 +0000 (09:37 +0800)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 28 Apr 2021 03:10:27 +0000 (05:10 +0200)
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 <fengchengwen@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
drivers/net/virtio/virtio_user_ethdev.c

index 79bd31e..e85906e 100644 (file)
@@ -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;
 }