aboutsummaryrefslogtreecommitdiff
path: root/hw/ide
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2017-10-20 10:14:03 +0100
committerJohn Snow <jsnow@redhat.com>2017-10-31 18:00:03 -0400
commit96f43c2b0a663f4789b51ed97297163321e7ba5e (patch)
treebda51e676fc1212eb1e5c011665594c5d721e75e /hw/ide
parent2585c67983d726da98fbfb8b742d722c39f885cf (diff)
downloadqemu-96f43c2b0a663f4789b51ed97297163321e7ba5e.zip
qemu-96f43c2b0a663f4789b51ed97297163321e7ba5e.tar.gz
qemu-96f43c2b0a663f4789b51ed97297163321e7ba5e.tar.bz2
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. 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>
Diffstat (limited to 'hw/ide')
-rw-r--r--hw/ide/core.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/ide/core.c b/hw/ide/core.c
index a04766a..471d0c9 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -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;