From patchwork Wed Aug 27 17:36:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 383512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 999BA140090 for ; Thu, 28 Aug 2014 03:40:44 +1000 (EST) Received: from localhost ([::1]:60795 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMhD8-0000mp-ON for incoming@patchwork.ozlabs.org; Wed, 27 Aug 2014 13:40:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60590) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMh9u-0003eG-LF for qemu-devel@nongnu.org; Wed, 27 Aug 2014 13:37:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMh9i-0002xR-0l for qemu-devel@nongnu.org; Wed, 27 Aug 2014 13:37:22 -0400 Received: from e9.ny.us.ibm.com ([32.97.182.139]:44700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMh9h-0002xF-Qp for qemu-devel@nongnu.org; Wed, 27 Aug 2014 13:37:09 -0400 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 27 Aug 2014 13:37:09 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 27 Aug 2014 13:37:06 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id B62D2C90067; Wed, 27 Aug 2014 13:36:57 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id s7RHb5XY64225370; Wed, 27 Aug 2014 17:37:05 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s7RHb58u009862; Wed, 27 Aug 2014 13:37:05 -0400 Received: from localhost ([9.80.81.153]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s7RHb53w009816; Wed, 27 Aug 2014 13:37:05 -0400 From: Michael Roth To: qemu-devel@nongnu.org Date: Wed, 27 Aug 2014 12:36:09 -0500 Message-Id: <1409160982-16389-13-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409160982-16389-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1409160982-16389-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14082717-7182-0000-0000-0000004D6BDB X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.182.139 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 12/25] virtio-blk: fix reference a pointer which might be freed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: zhanghailiang In function virtio_blk_handle_request, it may freed memory pointed by req, So do not access member of req after calling this function. Cc: qemu-stable@nongnu.org Reviewed-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi Signed-off-by: zhanghailiang Signed-off-by: Kevin Wolf (cherry picked from commit 1bdb176ac5add5dc9d54a230da7511b66851f1e7) Signed-off-by: Michael Roth --- hw/block/virtio-blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index c241c50..0e3925b 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -469,8 +469,9 @@ static void virtio_blk_dma_restart_bh(void *opaque) s->rq = NULL; while (req) { + VirtIOBlockReq *next = req->next; virtio_blk_handle_request(req, &mrb); - req = req->next; + req = next; } virtio_submit_multiwrite(s->bs, &mrb);