qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block/nfs: fix potential segfault on early callback
@ 2014-06-10  7:42 Peter Lieven
  2014-06-11 11:46 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Lieven @ 2014-06-10  7:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, pbonzini, Peter Lieven, stefanha

it will happen in the future that the callback of a libnfs call
directly invokes the callback. In this case we end up in a segfault
because the NFSRPC is gone when we the BH is scheduled.

Signed-off-by: Peter Lieven <pl@kamp.de>
---
 block/nfs.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/nfs.c b/block/nfs.c
index bd9177f..e282f8d 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -95,6 +95,7 @@ static void nfs_co_init_task(NFSClient *client, NFSRPC *task)
 static void nfs_co_generic_bh_cb(void *opaque)
 {
     NFSRPC *task = opaque;
+    task->complete = 1;
     qemu_bh_delete(task->bh);
     qemu_coroutine_enter(task->co, NULL);
 }
@@ -104,7 +105,6 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data,
                   void *private_data)
 {
     NFSRPC *task = private_data;
-    task->complete = 1;
     task->ret = ret;
     if (task->ret > 0 && task->iov) {
         if (task->ret <= task->iov->size) {
@@ -123,6 +123,8 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data,
         task->bh = aio_bh_new(task->client->aio_context,
                               nfs_co_generic_bh_cb, task);
         qemu_bh_schedule(task->bh);
+    } else {
+        task->complete = 1;
     }
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] block/nfs: fix potential segfault on early callback
  2014-06-10  7:42 [Qemu-devel] [PATCH] block/nfs: fix potential segfault on early callback Peter Lieven
@ 2014-06-11 11:46 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2014-06-11 11:46 UTC (permalink / raw)
  To: Peter Lieven; +Cc: kwolf, pbonzini, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 489 bytes --]

On Tue, Jun 10, 2014 at 09:42:47AM +0200, Peter Lieven wrote:
> it will happen in the future that the callback of a libnfs call
> directly invokes the callback. In this case we end up in a segfault
> because the NFSRPC is gone when we the BH is scheduled.
> 
> Signed-off-by: Peter Lieven <pl@kamp.de>
> ---
>  block/nfs.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-11 11:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-10  7:42 [Qemu-devel] [PATCH] block/nfs: fix potential segfault on early callback Peter Lieven
2014-06-11 11:46 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).