From patchwork Fri Oct 20 09:14:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 10019339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C0A3F603B5 for ; Fri, 20 Oct 2017 09:14:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B405228E88 for ; Fri, 20 Oct 2017 09:14:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A900B28EA3; Fri, 20 Oct 2017 09:14:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 59BB728E88 for ; Fri, 20 Oct 2017 09:14:56 +0000 (UTC) Received: from localhost ([::1]:52753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5TOJ-0003Sw-KM for patchwork-qemu-devel@patchwork.kernel.org; Fri, 20 Oct 2017 05:14:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5TNd-0003Qr-39 for qemu-devel@nongnu.org; Fri, 20 Oct 2017 05:14:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5TNc-0008WA-9j for qemu-devel@nongnu.org; Fri, 20 Oct 2017 05:14:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37426) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5TNY-0008U6-3R; Fri, 20 Oct 2017 05:14:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1801760178; Fri, 20 Oct 2017 09:14:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1801760178 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from t460.redhat.com (unknown [10.33.36.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id B10E6614C5; Fri, 20 Oct 2017 09:14:05 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Fri, 20 Oct 2017 10:14:03 +0100 Message-Id: <20171020091403.1479-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 20 Oct 2017 09:14:07 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] ide: avoid referencing NULL dev in rotational rate setting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Stefan Hajnoczi --- hw/ide/core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index a04766aee7..471d0c928b 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;