From patchwork Wed May 29 12:12:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Hrdina X-Patchwork-Id: 247260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 61C4E2C02AD for ; Wed, 29 May 2013 22:13:04 +1000 (EST) Received: from localhost ([::1]:45318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfFW-0003bH-GU for incoming@patchwork.ozlabs.org; Wed, 29 May 2013 08:13:02 -0400 Received: from eggs.gnu.org ([208.118.235.92]:34736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfEu-0003MA-1U for qemu-devel@nongnu.org; Wed, 29 May 2013 08:12:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhfEm-0005Ug-9Y for qemu-devel@nongnu.org; Wed, 29 May 2013 08:12:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfEl-0005U9-Vo for qemu-devel@nongnu.org; Wed, 29 May 2013 08:12:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4TCCFZl023877 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 May 2013 08:12:15 -0400 Received: from antique-laptop.brq.redhat.com (dhcp-26-113.brq.redhat.com [10.34.26.113]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4TCCCWv030842; Wed, 29 May 2013 08:12:14 -0400 From: Pavel Hrdina To: qemu-devel@nongnu.org Date: Wed, 29 May 2013 14:12:10 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, pbonzini@redhat.com, phrdina@redhat.com Subject: [Qemu-devel] [PATCH 1/2] scsi-generic: check the return value of bdrv_aio_ioctl in execute_command X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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; }