From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuHC8-0004NV-LD for qemu-devel@nongnu.org; Tue, 10 Jun 2014 04:14:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WuHC0-0002Gp-My for qemu-devel@nongnu.org; Tue, 10 Jun 2014 04:14:12 -0400 Received: from mx-v6.kamp.de ([2a02:248:0:51::16]:51615 helo=mx01.kamp.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WuHC0-0002Ge-CO for qemu-devel@nongnu.org; Tue, 10 Jun 2014 04:14:04 -0400 Message-ID: <5396BE48.5010408@kamp.de> Date: Tue, 10 Jun 2014 10:14:00 +0200 From: Peter Lieven MIME-Version: 1.0 References: <1402386736-11673-1-git-send-email-pl@kamp.de> <5396BD0E.8030300@redhat.com> In-Reply-To: <5396BD0E.8030300@redhat.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] block/iscsi: fix potential segfault on early callback List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com On 10.06.2014 10:08, Paolo Bonzini wrote: > Il 10/06/2014 09:52, Peter Lieven ha scritto: >> it might happen in the future that a function directly invokes its callback. >> In this case we end up in a segfault because the iTask is gone when the BH >> is scheduled. >> >> Signed-off-by: Peter Lieven >> --- >> block/iscsi.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/block/iscsi.c b/block/iscsi.c >> index 019b324..4bf4238 100644 >> --- a/block/iscsi.c >> +++ b/block/iscsi.c >> @@ -146,6 +146,7 @@ iscsi_schedule_bh(IscsiAIOCB *acb) >> static void iscsi_co_generic_bh_cb(void *opaque) >> { >> struct IscsiTask *iTask = opaque; >> + iTask->complete = 1; >> qemu_bh_delete(iTask->bh); >> qemu_coroutine_enter(iTask->co, NULL); >> } >> @@ -153,6 +154,7 @@ static void iscsi_co_generic_bh_cb(void *opaque) >> static void iscsi_retry_timer_expired(void *opaque) >> { >> struct IscsiTask *iTask = opaque; >> + iTask->complete = 1; >> if (iTask->co) { >> qemu_coroutine_enter(iTask->co, NULL); >> } >> @@ -171,7 +173,6 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, >> struct IscsiTask *iTask = opaque; >> struct scsi_task *task = command_data; >> >> - iTask->complete = 1; >> iTask->status = status; >> iTask->do_retry = 0; >> iTask->task = task; >> @@ -209,6 +210,8 @@ out: >> iTask->bh = aio_bh_new(iTask->iscsilun->aio_context, >> iscsi_co_generic_bh_cb, iTask); >> qemu_bh_schedule(iTask->bh); >> + } else { >> + iTask->complete = 1; >> } >> } >> >> > > Applied, thanks. I'll leave the nfs patch to Kevin and/or Stefan. Thank you, Stefan/Kevin I messed up the commit message. Can you please fix when picking up: ---8<--- it will happen in the future that a function directly invokes its callback. In this case we end up in a segfault because the NFSRPC is gone when we the BH is scheduled. --->8--- Thanks, Peter