fsdev: Fix potential memory leak
PATCH 1/1 fsdev: Fix potential memory leak
This leak was reported by cppcheck.
--- fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+)
fsdev/qemu-fsdev.c +2 -0
@@ -76,6 +76,8 @@ int qemu_fsdev_add(QemuOpts *opts)if (fsle->fse.ops->parse_opts) {if (fsle->fse.ops->parse_opts (opts, &fsle->fse)) { +g_free (fsle->fse.fsdev_id); +g_free (fsle);return -1 ; } }
Signature · 1 line
1.7.10.4
Am 16.06.2013 12:02, schrieb Stefan Weil:
Quoted 12 lines
This leak was reported by cppcheck.
Signed-off-by Stefan Weil <[email protected]>--- fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+)fsdev/qemu-fsdev.c +0
-0
fsdev/qemu-fsdev.c int qemu_fsdev_add(QemuOpts *opts) · line 83
Quoted 8 lines
fsdev/qemu-fsdev.c +2
-0@@ -76,6 +76,8 @@ int qemu_fsdev_add(QemuOpts *opts)if (fsle->fse.ops->parse_opts) {if (fsle->fse.ops->parse_opts (opts, &fsle->fse)) { +g_free (fsle->fse.fsdev_id); +g_free (fsle);return -1 ; } }
Ping?
Quoted 14 lines · Stefan Weil
Am 16.06.2013 12:02, schrieb Stefan Weil:
Quoted 13 lines
This leak was reported by cppcheck.
Signed-off-by Stefan Weil <[email protected]>--- fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+)fsdev/qemu-fsdev.c +0
-0@@ -76,6 +76,8 @@ int qemu_fsdev_add(QemuOpts *opts)
Quoted 9 lines
fsdev/qemu-fsdev.c int qemu_fsdev_add(QemuOpts *opts) · line 83
Quoted 7 lines
fsdev/qemu-fsdev.c +2
-0if (fsle->fse.ops->parse_opts) {if (fsle->fse.ops->parse_opts (opts, &fsle->fse)) { +g_free (fsle->fse.fsdev_id); +g_free (fsle);return -1 ; } }Ping?
Both the error path result in Qemu terminating right ? Do we really care about free in those case ?
-aneesh
Am 07.07.2013 19:15, schrieb Aneesh Kumar K.V:
Quoted 24 lines
Quoted 14 lines · Stefan Weil
Am 16.06.2013 12:02, schrieb Stefan Weil:
Quoted 13 lines
This leak was reported by cppcheck.
Signed-off-by Stefan Weil <[email protected]>--- fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+)fsdev/qemu-fsdev.c +0
-0@@ -76,6 +76,8 @@ int qemu_fsdev_add(QemuOpts *opts)Quoted 8 lines
fsdev/qemu-fsdev.c int qemu_fsdev_add(QemuOpts *opts) · line 83
Quoted 7 lines
fsdev/qemu-fsdev.c +2
-0if (fsle->fse.ops->parse_opts) {if (fsle->fse.ops->parse_opts (opts, &fsle->fse)) { +g_free (fsle->fse.fsdev_id); +g_free (fsle);return -1 ; } }Ping?
Quoted 4 lines
Both the error path result in Qemu terminating right ? Do we really care about free in those case ?
-aneesh
Yes, we do, because it simplifies code reviews if there are as few as possible warnings from static code analysers.
It is also not immediately obvious that QEMU terminates in the code which was patched here. Reviewers have to grep and look in vl.c, too, to see this.
Therefore I'd appreciate if this and similar code could be fixed (with low priority here).
Regards
Stefan W.
Quoted 3 lines · Stefan Weil
This leak was reported by cppcheck.
Signed-off-by Stefan Weil <[email protected]>
Quoted 19 lines
--- fsdev/qemu-fsdev.c | 2 ++ 1 file changed, 2 insertions(+)fsdev/qemu-fsdev.c +2
-0@@ -76,6 +76,8 @@ int qemu_fsdev_add(QemuOpts *opts)if (fsle->fse.ops->parse_opts) {if (fsle->fse.ops->parse_opts (opts, &fsle->fse)) { +g_free (fsle->fse.fsdev_id); +g_free (fsle);return -1 ; } }Signature · 1 line
1.7.10.4
Anthony Liguori
AppliedApplied. Thanks.
Regards,
Anthony Liguori