[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] qemu: avoid pass null pointer as an argument



On 08/04/2011 07:10 PM, Alex Jia wrote:
We definitely have a bug here, but this is not the right fix. The bug
is that the cleanup: label is trying to read from logfd if the vm
crashed, without having opened logfd in the qemuProcessAttach case.

I think the more appropriate patch is this:

diff --git i/src/qemu/qemu_process.c w/src/qemu/qemu_process.c
index 8508ff6..1eea45f 100644
--- i/src/qemu/qemu_process.c
+++ w/src/qemu/qemu_process.c
@@ -1214,7 +1214,7 @@ qemuProcessWaitForMonitor(struct qemud_driver*
driver,
cleanup:
virHashFree(paths);

- if (kill(vm->pid, 0) == -1 && errno == ESRCH) {
+ if (pos != -1 && kill(vm->pid, 0) == -1 && errno == ESRCH) {
/* VM is dead, any other error raised in the interim is probably
* not as important as the qemu cmdline output */
qemuProcessReadLogFD(logfd, buf, buf_size, strlen(buf));

Agree, it indeed is a issue, I will check 'null pointer' issue with
thiis fixed again, to avoid some warning from ccc-analyzer, if you set
up this env, please also check it.

With that, I've gone ahead and pushed this, which also included fixing the double VIR_FREE.

--
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]