Skip to contentSkip to conversation

ide: avoid referencing NULL dev in rotational rate setting

PATCH In review Daniel P. Berrange 2 participants 4 messages Oct 20, 2017 – Oct 24, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ide: avoid referencing NULL dev in rotational rate setting

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.

---
 hw/ide/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/ide/core.c +3 -1
index a04766aee7..471d0c928b 100644
@@ -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;
Signature · 1 line
2.13.6
#2 lore raw
In reply to Daniel P. Berrange

CC John

Quoted 26 lines · Daniel P. Berrange

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.

---
 hw/ide/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
hw/ide/core.c +3 -1
index a04766aee7..471d0c928b 100644
@@ -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;
Signature · 1 line
2.13.6

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw
Quoted 1 line · Daniel P. Berrange

CC John

Feel free to ping me if John doesn't respond by next Wednesday and I'll merge this trivial fix.

Stefan