]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
ide: avoid referencing NULL dev in rotational rate setting
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 20 Oct 2017 09:14:03 +0000 (10:14 +0100)
committerJohn Snow <jsnow@redhat.com>
Tue, 31 Oct 2017 22:00:03 +0000 (18:00 -0400)
The 'dev' variable can be NULL when the guest OS calls identify on an IDE
unit that does not have a drive attached to it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20171020091403.1479-1-berrange@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>
hw/ide/core.c

index a04766aee7172dfdcf62e6e70febb24d557d6fcf..471d0c928b55ce8bc59acc66ff2d61ac6a1f892b 100644 (file)
@@ -208,7 +208,9 @@ static void ide_identify(IDEState *s)
     if (dev && dev->conf.discard_granularity) {
         put_le16(p + 169, 1); /* TRIM support */
     }
-    put_le16(p + 217, dev->rotation_rate); /* Nominal media rotation rate */
+    if (dev) {
+        put_le16(p + 217, dev->rotation_rate); /* Nominal media rotation rate */
+    }
 
     ide_identify_size(s);
     s->identify_set = 1;