From patchwork Thu Aug 13 16:51:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 11712713 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 6A7A913A4 for ; Thu, 13 Aug 2020 16:52:38 +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 0032120774 for ; Thu, 13 Aug 2020 16:52:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="oFMe7BMX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0032120774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.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]:34542 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6GSz-0000Ib-1j for patchwork-qemu-devel@patchwork.kernel.org; Thu, 13 Aug 2020 12:52:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6GSZ-0008Jr-6x for qemu-devel@nongnu.org; Thu, 13 Aug 2020 12:52:11 -0400 Received: from mail-m971.mail.163.com ([123.126.97.1]:42688) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6GSU-000463-9p for qemu-devel@nongnu.org; Thu, 13 Aug 2020 12:52:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=qgOBh8DEWIr+1eiPh0 iebBExJiaGflRdaHFUtmrAabY=; b=oFMe7BMXxW9mkqxWcRDt3Pu1K83ypmgHLr sL4Xh6iEQbuaz10CvEVDRuIPJ7FCbmJ7tkSLu1pCW+6pz1l611s/+ISifB8qLAEc Ccm1bZX4J0Y2QOyG+d4ShBapuWea8qL66F1wwK32n4Iz1iSakjHKHZyc+hS7oMOB MpqK9AFZE= Received: from localhost.localdomain (unknown [115.204.177.14]) by smtp1 (Coremail) with SMTP id GdxpCgA3xNCVbzVffgB5Ag--.40S4; Fri, 14 Aug 2020 00:51:56 +0800 (CST) From: Li Qiang To: mst@redhat.com Subject: [PATCH] hw: virtio-pmem: detach the element fromt the virtqueue when error occurs Date: Thu, 13 Aug 2020 09:51:25 -0700 Message-Id: <20200813165125.59928-1-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: GdxpCgA3xNCVbzVffgB5Ag--.40S4 X-Coremail-Antispam: 1Uf129KBjvdXoWrKr4rZry5Cw1UXw4DKFW7urg_yoW3ArX_GF W8CayxWw4jga4akrWjyw4rXF1fGa18W3Z8AF13tF18Ar18Jw45JF9rXFsY9F17WrW8Ka15 ArZ5Krs8Wwn3ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7xRE7Ks7UUUUU== X-Originating-IP: [115.204.177.14] X-CM-SenderInfo: 5oltjvrd6rljoofrz/1tbitA5-bVSIiR1jTgAAsN Received-SPF: pass client-ip=123.126.97.1; envelope-from=liq3ea@163.com; helo=mail-m971.mail.163.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 11:36:23 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-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: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" If error occurs while processing the virtio request we should call 'virtqueue_detach_element' to detach the element from the virtqueue before free the elem. Signed-off-by: Li Qiang Reviewed-by: Pankaj Gupta --- hw/virtio/virtio-pmem.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index 1e0c137497..ddb0125901 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -77,6 +77,7 @@ static void virtio_pmem_flush(VirtIODevice *vdev, VirtQueue *vq) if (req_data->elem.out_num < 1 || req_data->elem.in_num < 1) { virtio_error(vdev, "virtio-pmem request not proper"); + virtqueue_detach_element(vq, (VirtQueueElement *)req_data, 0); g_free(req_data); return; }