From patchwork Fri Aug 21 08:49:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zhijian X-Patchwork-Id: 11728639 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 65E69722 for ; Fri, 21 Aug 2020 08:50:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05F8C208DB for ; Fri, 21 Aug 2020 08:50:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 05F8C208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=cn.fujitsu.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:47682 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k92kw-00033a-RN for patchwork-qemu-devel@patchwork.kernel.org; Fri, 21 Aug 2020 04:50:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k92kR-0002bA-Qo for qemu-devel@nongnu.org; Fri, 21 Aug 2020 04:50:07 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:15207 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k92kQ-0007D4-4K for qemu-devel@nongnu.org; Fri, 21 Aug 2020 04:50:07 -0400 X-IronPort-AV: E=Sophos;i="5.76,335,1592841600"; d="scan'208";a="98383466" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 21 Aug 2020 16:50:02 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 2056848990CF; Fri, 21 Aug 2020 16:49:57 +0800 (CST) Received: from G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.203) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 21 Aug 2020 16:49:58 +0800 Received: from G08FNSTD190042.g08.fujitsu.local (10.167.226.45) by G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 21 Aug 2020 16:49:57 +0800 From: Li Zhijian To: "Michael S. Tsirkin" , Gerd Hoffmann Subject: [PATCH] virtio-gpu: fix unmap the already mapped items Date: Fri, 21 Aug 2020 16:49:45 +0800 Message-ID: <20200821084945.5264-1-lizhijian@cn.fujitsu.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 2056848990CF.AD295 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: lizhijian@cn.fujitsu.com Received-SPF: none client-ip=183.91.158.132; envelope-from=lizhijian@cn.fujitsu.com; helo=heian.cn.fujitsu.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/21 03:09:06 X-ACL-Warn: Detected OS = ??? X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: qemu-devel@nongnu.org, Li Zhijian Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" we go here either (!(*iov)[i].iov_base) or (len != l), so we need to consider to unmap the 'i'th item as well when the 'i'th item is not nil Signed-off-by: Li Zhijian --- hw/display/virtio-gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 5f0dd7c150..1f777e43ff 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -656,7 +656,7 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, qemu_log_mask(LOG_GUEST_ERROR, "%s: failed to map MMIO memory for" " resource %d element %d\n", __func__, ab->resource_id, i); - virtio_gpu_cleanup_mapping_iov(g, *iov, i); + virtio_gpu_cleanup_mapping_iov(g, *iov, i + !!(*iov)[i].iov_base); g_free(ents); *iov = NULL; if (addr) {