Patchwork nbd: Fix uninitialised use of s->sock

login
register
mail settings
Submitter Kevin Wolf
Date April 26, 2012, 11:45 a.m.
Message ID <1335440730-27180-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/155252/
State New
Headers show

Comments

Kevin Wolf - April 26, 2012, 11:45 a.m.
s->sock is assigned only afterwards, so we're really registering an
aio_fd_handler for file descriptor 0 here. Not exactly what we intended.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/nbd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Paolo Bonzini - April 26, 2012, 3:56 p.m.
Il 26/04/2012 13:45, Kevin Wolf ha scritto:
> s->sock is assigned only afterwards, so we're really registering an
> aio_fd_handler for file descriptor 0 here. Not exactly what we intended.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/nbd.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/block/nbd.c b/block/nbd.c
> index 56dbf6e..1212614 100644
> --- a/block/nbd.c
> +++ b/block/nbd.c
> @@ -284,7 +284,7 @@ static int nbd_establish_connection(BlockDriverState *bs)
>      /* Now that we're connected, set the socket to be non-blocking and
>       * kick the reply mechanism.  */
>      socket_set_nonblock(sock);
> -    qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL,
> +    qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL,
>                              nbd_have_request, s);
>  
>      s->sock = sock;

Thanks, applied and pull request sent.

Paolo

Patch

diff --git a/block/nbd.c b/block/nbd.c
index 56dbf6e..1212614 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -284,7 +284,7 @@  static int nbd_establish_connection(BlockDriverState *bs)
     /* Now that we're connected, set the socket to be non-blocking and
      * kick the reply mechanism.  */
     socket_set_nonblock(sock);
-    qemu_aio_set_fd_handler(s->sock, nbd_reply_ready, NULL,
+    qemu_aio_set_fd_handler(sock, nbd_reply_ready, NULL,
                             nbd_have_request, s);
 
     s->sock = sock;