From patchwork Mon Apr 29 23:51:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Rogers X-Patchwork-Id: 10922597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 105C11390 for ; Mon, 29 Apr 2019 23:52:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E89F82895F for ; Mon, 29 Apr 2019 23:52:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D76DA28A13; Mon, 29 Apr 2019 23:52:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 691762895F for ; Mon, 29 Apr 2019 23:52:11 +0000 (UTC) Received: from localhost ([127.0.0.1]:36673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLG4A-0002AR-98 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 29 Apr 2019 19:52:10 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLG3V-0001rg-8a for qemu-devel@nongnu.org; Mon, 29 Apr 2019 19:51:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLG3T-00019R-8x for qemu-devel@nongnu.org; Mon, 29 Apr 2019 19:51:29 -0400 Received: from inet-orm.provo.novell.com ([137.65.248.124]:50118 helo=mail.novell.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hLG3T-00018N-2m for qemu-devel@nongnu.org; Mon, 29 Apr 2019 19:51:27 -0400 Received: from brogers1.provo.novell.com ([137.65.223.135]) by mail.novell.com with ESMTP (NOT encrypted); Mon, 29 Apr 2019 17:51:18 -0600 From: Bruce Rogers To: qemu-devel@nongnu.org Date: Mon, 29 Apr 2019 17:51:09 -0600 Message-Id: <20190429235109.20307-1-brogers@suse.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 137.65.248.124 Subject: [Qemu-devel] [PATCH] scsi-disk: handle invalid cdb length X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, pbonzini@redhat.com, Bruce Rogers Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP While investigating link-time-optimization, the compiler flagged this case of not handling the error return from scsi_cdb_length(). Handle this error case with a trace report. Signed-off-by: Bruce Rogers --- hw/scsi/scsi-disk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index e7e865ab3b..dc13c892ef 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2520,6 +2520,10 @@ static void scsi_disk_new_request_dump(uint32_t lun, uint32_t tag, uint8_t *buf) int len = scsi_cdb_length(buf); char *line_buffer, *p; + if (len < 0) { + trace_scsi_disk_new_request(lun, tag, "bad cdb length!"); + return; + } line_buffer = g_malloc(len * 5 + 1); for (i = 0, p = line_buffer; i < len; i++) {