From patchwork Fri Jul 12 07:35:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pankaj Gupta X-Patchwork-Id: 11041653 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C67B21395 for ; Fri, 12 Jul 2019 07:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B631828BAD for ; Fri, 12 Jul 2019 07:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A9DC428BC5; Fri, 12 Jul 2019 07:36:53 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6074428BAD for ; Fri, 12 Jul 2019 07:36:53 +0000 (UTC) Received: from localhost ([::1]:47200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlq6u-0001KC-EW for patchwork-qemu-devel@patchwork.kernel.org; Fri, 12 Jul 2019 03:36:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39077) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hlq6S-0007fT-N7 for qemu-devel@nongnu.org; Fri, 12 Jul 2019 03:36:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hlq6R-0000ot-Ku for qemu-devel@nongnu.org; Fri, 12 Jul 2019 03:36:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40255) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hlq6R-0000oK-FV for qemu-devel@nongnu.org; Fri, 12 Jul 2019 03:36:23 -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 50687C049589; Fri, 12 Jul 2019 07:36:21 +0000 (UTC) Received: from dhcp201-121.englab.pnq.redhat.com (ovpn-116-201.sin2.redhat.com [10.67.116.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 082F3608AB; Fri, 12 Jul 2019 07:36:17 +0000 (UTC) From: Pankaj Gupta To: mst@redhat.com Date: Fri, 12 Jul 2019 13:05:53 +0530 Message-Id: <20190712073554.21918-3-pagupta@redhat.com> In-Reply-To: <20190712073554.21918-1-pagupta@redhat.com> References: <20190712073554.21918-1-pagupta@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.31]); Fri, 12 Jul 2019 07:36:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/3] virtio pmem: remove memdev null check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pagupta@redhat.com, peter.maydell@linaro.org, cohuck@redhat.com, qemu-devel@nongnu.org, david@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Coverity reports that when we're assigning vi->size we handle the "pmem->memdev is NULL" case; but we then pass it into object_get_canonical_path(), which unconditionally dereferences it and will crash if it is NULL. If this pointer can be NULL then we need to do something else here. We are removing 'pmem->memdev' null check here as memdev will never be null in this function. Signed-off-by: Pankaj Gupta Reviewed-by: Cornelia Huck --- hw/virtio/virtio-pmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index adbfb603ab..17c196d107 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -134,8 +134,8 @@ static void virtio_pmem_fill_device_info(const VirtIOPMEM *pmem, VirtioPMEMDeviceInfo *vi) { vi->memaddr = pmem->start; - vi->size = pmem->memdev ? memory_region_size(&pmem->memdev->mr) : 0; - vi->memdev = object_get_canonical_path(OBJECT(pmem->memdev)); + vi->size = memory_region_size(&pmem->memdev->mr); + vi->memdev = object_get_canonical_path(OBJECT(pmem->memdev)); } static MemoryRegion *virtio_pmem_get_memory_region(VirtIOPMEM *pmem,