From patchwork Mon Sep 18 20:25:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manos Pitsidianakis X-Patchwork-Id: 9957619 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2D65E60208 for ; Mon, 18 Sep 2017 20:27:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F378286B8 for ; Mon, 18 Sep 2017 20:27:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13A2028D8B; Mon, 18 Sep 2017 20:27:06 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF6E1286B8 for ; Mon, 18 Sep 2017 20:27:04 +0000 (UTC) Received: from localhost ([::1]:38778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du2dE-0000JO-30 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 18 Sep 2017 16:27:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du2cc-0000J9-5Z for qemu-devel@nongnu.org; Mon, 18 Sep 2017 16:26:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1du2cY-0006nf-4B for qemu-devel@nongnu.org; Mon, 18 Sep 2017 16:26:26 -0400 Received: from smtp1.ntua.gr ([2001:648:2000:de::183]:57515) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1du2cX-0006mv-Op; Mon, 18 Sep 2017 16:26:22 -0400 Received: from mail.ntua.gr (carp0.noc.ntua.gr [147.102.222.60]) (authenticated bits=0) by smtp1.ntua.gr (8.15.2/8.15.2) with ESMTPSA id v8IKPd4b039612 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 18 Sep 2017 23:25:42 +0300 (EEST) (envelope-from el13635@mail.ntua.gr) X-Authentication-Warning: smtp1.ntua.gr: Host carp0.noc.ntua.gr [147.102.222.60] claimed to be mail.ntua.gr From: Manos Pitsidianakis To: qemu-block Date: Mon, 18 Sep 2017 23:25:29 +0300 Message-Id: <20170918202529.28379-1-el13635@mail.ntua.gr> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:648:2000:de::183 Subject: [Qemu-devel] [PATCH] block/throttle-groups.c: allocate RestartData on the heap X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Max Reitz , Alberto Garcia , qemu-devel , qemu-stable Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP RestartData is the opaque data of the throttle_group_restart_queue_entry coroutine. By being stack allocated, it isn't available anymore if aio_co_enter schedules the coroutine with a bottom halve and runs after throttle_group_restart_queue returns. Signed-off-by: Manos Pitsidianakis Reviewed-by: Eric Blake Reviewed-by: Alberto Garcia --- block/throttle-groups.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 6ba992c8d7..b291a88481 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -403,17 +403,19 @@ static void coroutine_fn throttle_group_restart_queue_entry(void *opaque) schedule_next_request(tgm, is_write); qemu_mutex_unlock(&tg->lock); } + + g_free(data); } static void throttle_group_restart_queue(ThrottleGroupMember *tgm, bool is_write) { Coroutine *co; - RestartData rd = { - .tgm = tgm, - .is_write = is_write - }; + RestartData *rd = g_new0(RestartData, 1); - co = qemu_coroutine_create(throttle_group_restart_queue_entry, &rd); + rd->tgm = tgm; + rd->is_write = is_write; + + co = qemu_coroutine_create(throttle_group_restart_queue_entry, rd); aio_co_enter(tgm->aio_context, co); }