[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 02/11] qga-win: handle NULL values
From: |
Tomáš Golembiovský |
Subject: |
[Qemu-devel] [PATCH v4 02/11] qga-win: handle NULL values |
Date: |
Thu, 4 Oct 2018 13:22:29 +0200 |
Handle returned NULLs properly to:
- avoid crashes in serialization.
- properly report errors to the caller
Signed-off-by: Tomáš Golembiovský <address@hidden>
---
qga/commands-win32.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 9c959122d9..49fc747298 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -735,6 +735,12 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid,
Error **errp)
}
fs->type = g_strdup(fs_name);
fs->disk = build_guest_disk_info(guid, errp);
+ if (fs->disk == NULL) {
+ g_free(fs);
+ fs = NULL;
+ goto free;
+ }
+
free:
g_free(mnt_point);
return fs;
@@ -755,7 +761,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
do {
GuestFilesystemInfo *info = build_guest_fsinfo(guid, errp);
if (info == NULL) {
- continue;
+ goto out;
}
new = g_malloc(sizeof(*ret));
new->value = info;
@@ -767,6 +773,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
error_setg_win32(errp, GetLastError(), "failed to find next volume");
}
+out:
FindVolumeClose(vol_h);
return ret;
}
--
2.19.0
- [Qemu-devel] [PATCH v4 00/11] qga: report serial number and disk node, Tomáš Golembiovský, 2018/10/04
- [Qemu-devel] [PATCH v4 05/11] qga-win: refactor disk properties (bus), Tomáš Golembiovský, 2018/10/04
- [Qemu-devel] [PATCH v4 07/11] qga: report disk serial number, Tomáš Golembiovský, 2018/10/04
- [Qemu-devel] [PATCH v4 02/11] qga-win: handle NULL values,
Tomáš Golembiovský <=
- [Qemu-devel] [PATCH v4 04/11] qga-win: add debugging information, Tomáš Golembiovský, 2018/10/04
- [Qemu-devel] [PATCH v4 10/11] qga: return disk device in guest-get-fsinfo, Tomáš Golembiovský, 2018/10/04
- [Qemu-devel] [PATCH v4 01/11] qga-win: fix crashes when PCI info cannot be retrived, Tomáš Golembiovský, 2018/10/04