From patchwork Sat Aug 15 14:19:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 1345253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=fT+8YfYn; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BTNvW1g6dz9sR4 for ; Sun, 16 Aug 2020 01:07:19 +1000 (AEST) Received: from localhost ([::1]:44606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6xm8-0002EC-VU for incoming@patchwork.ozlabs.org; Sat, 15 Aug 2020 11:07:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6xlM-0002AJ-UM for qemu-devel@nongnu.org; Sat, 15 Aug 2020 11:06:28 -0400 Received: from mail-m9763.mail.163.com ([123.126.97.63]:41318) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6xlJ-0007SE-G0 for qemu-devel@nongnu.org; Sat, 15 Aug 2020 11:06:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=W4LN/xZpHEZmo9POvK UpY0DPWTuEFUi8n4lDp6jU9qE=; b=fT+8YfYnQtTwQsd4DquO1va4bVxxURMoGu /MPWtaRamd3ubLj2Wkh0H8A3s96HvUUa1ua0DyX+bgsUlMu43t+0kct9w9cffvTy umbN4rILS3URTKlD3FXXXKl4RPxwGxL1JjzyehlBPh+RRJRVuaemumuG/XD5pfXU xUrICPwjs= Received: from localhost.localdomain (unknown [115.204.244.155]) by smtp1 (Coremail) with SMTP id GdxpCgA3w4MF7zdfSkGDAA--.134S5; Sat, 15 Aug 2020 22:20:00 +0800 (CST) From: Li Qiang To: hare@suse.com, pbonzini@redhat.com, fam@euphon.net Subject: [PATCH 1/2] hw: megasas: return -1 when 'megasas_map_sgl' fails Date: Sat, 15 Aug 2020 07:19:39 -0700 Message-Id: <20200815141940.44025-2-liq3ea@163.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200815141940.44025-1-liq3ea@163.com> References: <20200815141940.44025-1-liq3ea@163.com> X-CM-TRANSID: GdxpCgA3w4MF7zdfSkGDAA--.134S5 X-Coremail-Antispam: 1Uf129KBjvdXoW7JF4DZrWrWrW8XrW3uryxuFg_yoWDuFc_Aw 1093WkJr47Zr47J3sYqw1jyr12qwnrXFyDAr4aqasxAw13GasrGw4DX39rZFWkCw48urs8 twnayrZxAws5WjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU1b18JUUUUU== X-Originating-IP: [115.204.244.155] X-CM-SenderInfo: 5oltjvrd6rljoofrz/xtbBoRGBbVQHLOqJ+AAAs4 Received-SPF: pass client-ip=123.126.97.63; envelope-from=liq3ea@163.com; helo=mail-m9763.mail.163.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/15 03:37:13 X-ACL-Warn: Detected OS = Linux 3.1-3.10 X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , liq3ea@gmail.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The caller of 'megasas_map_sgl' will only check if the return is zero or not. If it return 0 it means success, as in the next patch we will consider 'iov_count=0' is an error, so let's return -1 to indicate a failure. Signed-off-by: Li Qiang --- hw/scsi/megasas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 5cfd1bf22e..d6c9680c36 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -281,7 +281,7 @@ static int megasas_map_sgl(MegasasState *s, MegasasCmd *cmd, union mfi_sgl *sgl) if (iov_count > MEGASAS_MAX_SGE) { trace_megasas_iovec_sgl_overflow(cmd->index, iov_count, MEGASAS_MAX_SGE); - return iov_count; + return -1; } pci_dma_sglist_init(&cmd->qsg, PCI_DEVICE(s), iov_count); for (i = 0; i < iov_count; i++) { @@ -311,7 +311,7 @@ static int megasas_map_sgl(MegasasState *s, MegasasCmd *cmd, union mfi_sgl *sgl) return 0; unmap: qemu_sglist_destroy(&cmd->qsg); - return iov_count - i; + return -1; } /*