Received: from eggs.gnu.org ([2001:4830:134:3::10]:48963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bi1V4-0000KW-B4 for qemu-devel@nongnu.org; Thu, 08 Sep 2016 11:44:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bi1V0-0003oi-KA for qemu-devel@nongnu.org; Thu, 08 Sep 2016 11:44:25 -0400 From: Paolo Bonzini Date: Thu, 8 Sep 2016 17:44:19 +0200 Message-Id: <1473349459-6178-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] Revert "megasas: remove useless check for cmd->frame" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: holger@fam-schranz.de, qemu-stable@nongnu.org This reverts commit 8cc46787b5b58f01a11c919c7ff939ed009e27fc. It turns out that cmd->frame can be NULL and thus the commit can cause a SIGSEGV Reported-by: Holger Schranz Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini --- hw/scsi/megasas.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index e968302..52a4123 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -1981,7 +1981,11 @@ static void megasas_handle_frame(MegasasState *s, uint64_t frame_addr, break; } if (frame_status != MFI_STAT_INVALID_STATUS) { - cmd->frame->header.cmd_status = frame_status; + if (cmd->frame) { + cmd->frame->header.cmd_status = frame_status; + } else { + megasas_frame_set_cmd_status(s, frame_addr, frame_status); + } megasas_unmap_frame(s, cmd); megasas_complete_frame(s, cmd->context); } -- 2.7.4