diff mbox

[1/2] scsi-generic: check the return value of bdrv_aio_ioctl in execute_command

Message ID bcf9b59a60a891864127a9000a5d9f7290a5d218.1369827988.git.phrdina@redhat.com
State New
Headers show

Commit Message

Pavel Hrdina May 29, 2013, 12:12 p.m. UTC
This fixes the bug introduced by this commit ad54ae80c73f.
The bdrv_aio_ioctl() still could return null and we should return an error
in that case.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 hw/scsi/scsi-generic.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Paolo Bonzini May 29, 2013, 12:22 p.m. UTC | #1
Il 29/05/2013 14:12, Pavel Hrdina ha scritto:
> This fixes the bug introduced by this commit ad54ae80c73f.
> The bdrv_aio_ioctl() still could return null and we should return an error
> in that case.
> 
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  hw/scsi/scsi-generic.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
> index 2a9a561..8a4dae2 100644
> --- a/hw/scsi/scsi-generic.c
> +++ b/hw/scsi/scsi-generic.c
> @@ -174,6 +174,10 @@ static int execute_command(BlockDriverState *bdrv,
>      r->io_header.flags |= SG_FLAG_DIRECT_IO;
>  
>      r->req.aiocb = bdrv_aio_ioctl(bdrv, SG_IO, &r->io_header, complete, r);
> +    if (r->req.aiocb == NULL) {
> +        BADF("execute_command: read failed !\n");
> +        return -EIO;
> +    }
>  
>      return 0;
>  }
> 

Applied to scsi branch with the BADF removed.  Thanks.

Paolo
diff mbox

Patch

diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 2a9a561..8a4dae2 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -174,6 +174,10 @@  static int execute_command(BlockDriverState *bdrv,
     r->io_header.flags |= SG_FLAG_DIRECT_IO;
 
     r->req.aiocb = bdrv_aio_ioctl(bdrv, SG_IO, &r->io_header, complete, r);
+    if (r->req.aiocb == NULL) {
+        BADF("execute_command: read failed !\n");
+        return -EIO;
+    }
 
     return 0;
 }