From patchwork Tue Apr 30 13:19:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Rogers X-Patchwork-Id: 10923441 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 7A4AD15A6 for ; Tue, 30 Apr 2019 13:21:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AD2928B87 for ; Tue, 30 Apr 2019 13:21:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5ED1D28B7D; Tue, 30 Apr 2019 13:21:42 +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 7F07428B8D for ; Tue, 30 Apr 2019 13:21:40 +0000 (UTC) Received: from localhost ([127.0.0.1]:47224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLShX-0006JJ-Iz for patchwork-qemu-devel@patchwork.kernel.org; Tue, 30 Apr 2019 09:21:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLSfw-0004z9-Pm for qemu-devel@nongnu.org; Tue, 30 Apr 2019 09:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLSfw-00054x-1M for qemu-devel@nongnu.org; Tue, 30 Apr 2019 09:20:00 -0400 Received: from inet-orm.provo.novell.com ([137.65.248.124]:49033 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 1hLSfv-00053e-OO for qemu-devel@nongnu.org; Tue, 30 Apr 2019 09:19:59 -0400 Received: from brogers1.provo.novell.com ([137.65.223.116]) by mail.novell.com with ESMTP (NOT encrypted); Tue, 30 Apr 2019 07:19:52 -0600 From: Bruce Rogers To: qemu-devel@nongnu.org Date: Tue, 30 Apr 2019 07:19:46 -0600 Message-Id: <20190430131946.26628-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 v2] 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..8fbf7512e5 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++) {