From patchwork Wed Oct 18 03:40:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sundeep subbaraya X-Patchwork-Id: 10013403 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F492602C8 for ; Wed, 18 Oct 2017 03:41:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8311F28A82 for ; Wed, 18 Oct 2017 03:41:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 765F328A9B; Wed, 18 Oct 2017 03:41:39 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0408B28A82 for ; Wed, 18 Oct 2017 03:41:38 +0000 (UTC) Received: from localhost ([::1]:42403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4fEe-0007rj-UV for patchwork-qemu-devel@patchwork.kernel.org; Tue, 17 Oct 2017 23:41:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4fE0-0007rZ-OS for qemu-devel@nongnu.org; Tue, 17 Oct 2017 23:40:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4fDx-0003hj-Ir for qemu-devel@nongnu.org; Tue, 17 Oct 2017 23:40:56 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:47075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4fDx-0003gy-Bb; Tue, 17 Oct 2017 23:40:53 -0400 Received: by mail-pg0-x244.google.com with SMTP id k7so3147876pga.3; Tue, 17 Oct 2017 20:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=F66Yg0n+E/IZA/m/3bHo3f5IQ47YYDmJJWqrJtX1Hd8=; b=UyoOH1hG1QVTrTTVgkQZkyNl3dwDqXqbCcNh6IDCd50k5Uqseu4pegOqEBsD9AUro2 nVMBdCqj8tEB0Zf8cvYUP7ow6Z5Z0/gc5W+dJSJ5cZC/LBk7fx/q1qTRNpHLDf2MhlKI f5Bn9wbMjJrqP/CFigb7Cm72lrXow0mAgGfx8s1yjdR5HKsxIOZiI1m2ze7Vni6zPsUP 8yrtCB3W9w9GlJVZqrLaHGJSXL2hCzVtll1XVPnKJsvBR0dURQ8MOKp4W2oG66B0Vdx3 j/5s/KyViDjVLkxCa8B7mP/voSUw/Iib/fcF5YfSKRDaxRoydWS0C5eT9IvNt7qTVzCq j/kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=F66Yg0n+E/IZA/m/3bHo3f5IQ47YYDmJJWqrJtX1Hd8=; b=jwg0aTAULvG5fom65Ok+Hmj7cVOOSfu1V0/I6xI9qXKcCS36LDB1jllD/ZgeJm29EV UWjOgTohblpfQpdC01c/N+yQfPvDvqKyMuN6uRS+4feTDZq6Qq5JyoBks3azQyyEhR5z 6XmfheaAGurE2JixqukqE45fgpm8ph2cwMG0ztZp2vRKzqXOb6gfUbbGRr9osCizLfJl mK75MZeAKlDhSlziDjnNlUIoWNcHoL7curD5u5UnZSAbet3Wo8Sk4A4kJ27ykEYOV0lQ a7rkCbe6xR21w42pUTrpWbUaUi5GKpC5f33ogA9JKo7N7PX2NpeM65Ag9V0ewqtaZWvW cbpg== X-Gm-Message-State: AMCzsaUTho7e++v8mRMfTwQypAC11D1iKc+kpNRPVDbz+Q+dqDTsTX0Y xg1whCySSXytaVNe7WFTEZmxTw== X-Google-Smtp-Source: AOwi7QB4y3Fpcnl2PC7nOHvPWmYFLt3fneotby/3urKzZUAT1FlD4Q/WiC73UePKaVl91h3B+VIpmw== X-Received: by 10.101.83.70 with SMTP id w6mr12460491pgr.361.1508298052143; Tue, 17 Oct 2017 20:40:52 -0700 (PDT) Received: from localhost.localdomain ([124.123.70.3]) by smtp.gmail.com with ESMTPSA id t25sm6295942pfh.67.2017.10.17.20.40.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 17 Oct 2017 20:40:51 -0700 (PDT) From: Subbaraya Sundeep To: qemu-devel@nongnu.org, qemu-arm@nongnu.org Date: Wed, 18 Oct 2017 09:10:38 +0530 Message-Id: <1508298038-4156-1-git-send-email-sundeep.lkml@gmail.com> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [Qemu devel v2 PATCH] msf2: Remove dead code reported by Coverity 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: peter.maydell@linaro.org, crosthwaite.peter@gmail.com, f4bug@amsat.org, alistair23@gmail.com, Subbaraya Sundeep , pbonzini@redhat.com, imammedo@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fixed incorrect frame size mask, validated maximum frame size in spi_write and removed dead code. Signed-off-by: Subbaraya Sundeep --- v2: else if -> else in set_fifodepth log guest error when frame size is more than 32 hw/ssi/mss-spi.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/ssi/mss-spi.c b/hw/ssi/mss-spi.c index 5a8e308..7fef2c3 100644 --- a/hw/ssi/mss-spi.c +++ b/hw/ssi/mss-spi.c @@ -76,9 +76,10 @@ #define C_BIGFIFO (1 << 29) #define C_RESET (1 << 31) -#define FRAMESZ_MASK 0x1F +#define FRAMESZ_MASK 0x3F #define FMCOUNT_MASK 0x00FFFF00 #define FMCOUNT_SHIFT 8 +#define FRAMESZ_MAX 32 static void txfifo_reset(MSSSpiState *s) { @@ -104,10 +105,8 @@ static void set_fifodepth(MSSSpiState *s) s->fifo_depth = 32; } else if (size <= 16) { s->fifo_depth = 16; - } else if (size <= 32) { - s->fifo_depth = 8; } else { - s->fifo_depth = 4; + s->fifo_depth = 8; } } @@ -301,6 +300,11 @@ static void spi_write(void *opaque, hwaddr addr, if (s->enabled) { break; } + if ((value & FRAMESZ_MASK) > FRAMESZ_MAX) { + qemu_log_mask(LOG_GUEST_ERROR, "%s: Maximum frame size is %d\n", + __func__, FRAMESZ_MAX); + break; + } s->regs[R_SPI_DFSIZE] = value; break;