From patchwork Wed Jul 31 23:59:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 263841 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 660932C00AF for ; Thu, 1 Aug 2013 10:00:23 +1000 (EST) Received: from localhost ([::1]:60157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4gJY-0002j3-Pv for incoming@patchwork.ozlabs.org; Wed, 31 Jul 2013 20:00:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4gJD-0002gH-VW for qemu-devel@nongnu.org; Wed, 31 Jul 2013 20:00:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V4gJ7-0005lq-TX for qemu-devel@nongnu.org; Wed, 31 Jul 2013 19:59:59 -0400 Received: from cantor2.suse.de ([195.135.220.15]:57393 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V4gJ7-0005ll-NZ for qemu-devel@nongnu.org; Wed, 31 Jul 2013 19:59:53 -0400 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A413CA50E4; Thu, 1 Aug 2013 01:59:52 +0200 (CEST) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Thu, 1 Aug 2013 01:59:47 +0200 Message-Id: <1375315187-16534-1-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.8.1.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Anthony Liguori , =?UTF-8?q?Andreas=20F=C3=A4rber?= , "Aneesh Kumar K.V" Subject: [Qemu-devel] [PATCH for-1.6] virtio-9p-device: Avoid freeing uninitialized memory 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 In virtio_9p_device_init() there are 6x goto out that will lead to v9fs_path_free() attempting to free unitialized path.data field. Easiest way to trigger is: qemu-system-x86_64 -device virtio-9p-pci Fix this by moving v9fs_path_init() before any goto out. Signed-off-by: Andreas Färber --- hw/9pfs/virtio-9p-device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index de6f0fe..f0ffbe8 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -61,6 +61,8 @@ static int virtio_9p_device_init(VirtIODevice *vdev) s->vq = virtio_add_queue(vdev, MAX_REQ, handle_9p_output); + v9fs_path_init(&path); + fse = get_fsdev_fsentry(s->fsconf.fsdev_id); if (!fse) { @@ -111,7 +113,6 @@ static int virtio_9p_device_init(VirtIODevice *vdev) * call back to do that. Since we are in the init path, we don't * use co-routines here. */ - v9fs_path_init(&path); if (s->ops->name_to_path(&s->ctx, NULL, "/", &path) < 0) { fprintf(stderr, "error in converting name to path %s", strerror(errno));