]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
check if console/channel PTY is null before attempting to open
authorShivaprasad G Bhat <shivaprasadbhat@gmail.com>
Sun, 31 May 2015 15:55:59 +0000 (21:25 +0530)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 3 Jun 2015 16:13:06 +0000 (18:13 +0200)
Console/channel devices have their pty devices assigned when the emulator is
actually started. If time is spent in guest preparation, someone attempts
to open the console/channel, the libvirt crashes in virChrdevLockFilePath().
The patch attempts to fix the crash by adding a check before attempting to
open.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
src/conf/virchrdev.c

index 5f28f2978bf6deffa847ed2e51e07a1c959800a5..701b326fb26e77e978232de4cc42c04a73e749bb 100644 (file)
@@ -350,6 +350,11 @@ int virChrdevOpen(virChrdevsPtr devs,
     switch (source->type) {
     case VIR_DOMAIN_CHR_TYPE_PTY:
         path = source->data.file.path;
+        if (!path) {
+            virReportError(VIR_ERR_OPERATION_FAILED, "%s",
+                           _("PTY device is not yet assigned"));
+            return -1;
+        }
         break;
     case VIR_DOMAIN_CHR_TYPE_UNIX:
         path = source->data.nix.path;