OSDN Git Service

vhost: fix a memory leak
authorPeng Hao <peng.hao2@zte.com.cn>
Tue, 4 Jul 2017 22:33:32 +0000 (06:33 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 1 Aug 2017 21:13:25 +0000 (00:13 +0300)
vhost exists a call for g_file_get_contents, but not call g_free.

Signed-off-by: Peng Hao<peng.hao2@zte.com.cn>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
hw/virtio/vhost-backend.c

index cb055e8..7f09efa 100644 (file)
@@ -52,11 +52,13 @@ static int vhost_kernel_memslots_limit(struct vhost_dev *dev)
                             &s, NULL, NULL)) {
         uint64_t val = g_ascii_strtoull(s, NULL, 10);
         if (!((val == G_MAXUINT64 || !val) && errno)) {
+            g_free(s);
             return val;
         }
         error_report("ignoring invalid max_mem_regions value in vhost module:"
                      " %s", s);
     }
+    g_free(s);
     return limit;
 }