From patchwork Wed Nov 4 10:22:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 316193 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E4F1C2D0A3 for ; Wed, 4 Nov 2020 10:27:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C9E2F206C1 for ; Wed, 4 Nov 2020 10:27:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9E2F206C1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=irrelevant.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaG0M-0008GQ-J1 for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 05:27:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40806) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaFwP-0003Sy-OA; Wed, 04 Nov 2020 05:22:57 -0500 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:46725) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaFwN-0002Gz-Jg; Wed, 04 Nov 2020 05:22:57 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 07168AED; Wed, 4 Nov 2020 05:22:52 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 04 Nov 2020 05:22:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=CAmto1w6XHX6Q WY+w0wNuJJUjSX8ez69FJ/6/YTcfcg=; b=OUt8c+lo36rinPl393LlU9W1imcgp eh8bumuMuVjK11npgDU42NRFwZJ7CLYEGaaneNzcDLTkS9wci0TnRrHazxCJGcxK ruNoCFnDMC3713hXuFMrRN7R3VTTn0FTWPi9a55hfdfyIPKnK8IutR5wT8S0LcOl aWmAO48T8g5jBsRDBOsGKBV8rJXAwfIUY2HgD8pxBK53IopCj9Id6cggnSAhVUrL x+Fl8Rnem0vDnaTLgIpnNLSH3hSAymlceCbDb1DX44+xBie2G3r4440ECwInbneO 68Z+tz0oAjiB6uI2FWbzUGr4CE9jIcNNvIoLDTHPvkiQbOs3u0pcQAg7w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=CAmto1w6XHX6QWY+w0wNuJJUjSX8ez69FJ/6/YTcfcg=; b=Sdj8VjSP 5VBAkZQkXinyNMJ0owAASryyLqpYJqdmTTQFUZEQqdututG4mebMHFgr0fLSje3b D5i1AjxzIoVRAZIqhrSnsRwcCnfqXYV3DGbVObVdsMXTlbSWpS+vI14mGf6/LChL muYo/ryJ4MfS3kUcnlwLhujI4qX1+1fdSSAaCIrkO4CDg9CFFacWyuEclyEgywQB oqMuBMCeNaKfy0OjuxotHs+IWhAldiYyusKNdvoXnni8YZ9jU7OWbINtN3xzdk7b 1PSQQ1e//5yJruBmEJh/+1IubRrIoc3Ua3iyElHK8heceVrJc96NkpH1amiKkN+S Hn8IhQqyubU1mg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddthedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id 209793280390; Wed, 4 Nov 2020 05:22:51 -0500 (EST) From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 1/3] hw/block/nvme: fix null ns in register namespace Date: Wed, 4 Nov 2020 11:22:46 +0100 Message-Id: <20201104102248.32168-2-its@irrelevant.dk> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104102248.32168-1-its@irrelevant.dk> References: <20201104102248.32168-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/04 05:22:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Dmitry Fomichev , Klaus Jensen , Max Reitz , Keith Busch , Minwoo Im , Klaus Jensen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Fix dereference after NULL check. Reported-by: Coverity (CID 1436128) Fixes: b20804946bce ("hw/block/nvme: update nsid when registered") Signed-off-by: Klaus Jensen Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daudé --- hw/block/nvme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index fa2cba744b57..080d782f1c2b 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -2562,8 +2562,7 @@ int nvme_register_namespace(NvmeCtrl *n, NvmeNamespace *ns, Error **errp) if (!nsid) { for (int i = 1; i <= n->num_namespaces; i++) { - NvmeNamespace *ns = nvme_ns(n, i); - if (!ns) { + if (!nvme_ns(n, i)) { nsid = ns->params.nsid = i; break; } From patchwork Wed Nov 4 10:22:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 316192 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8EE00C2D0A3 for ; Wed, 4 Nov 2020 10:31:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C4C04206D4 for ; Wed, 4 Nov 2020 10:31:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C4C04206D4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=irrelevant.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:40478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kaG4T-0002Pl-8j for qemu-devel@archiver.kernel.org; Wed, 04 Nov 2020 05:31:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaFwQ-0003Uy-Vw; Wed, 04 Nov 2020 05:22:59 -0500 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:33625) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kaFwO-0002Hj-Ee; Wed, 04 Nov 2020 05:22:58 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 6885C3D5; Wed, 4 Nov 2020 05:22:54 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 04 Nov 2020 05:22:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=UA+VVCnGzkkNI uqKXObtavL8wxUG01U2iUsM9Tmlh44=; b=BM/q3bo/I6Yb8FmWFFvq8L7MmQ2hY JCt+6mUKjXSGM/O7LxS4rHyTy3tTts+h3IXPLqpUE/7etEH/mvTmkpKxhhAfxu+X 2WF1JQKLzDzs9T51ud0wThWBuu1XAFY8HyhZ6rm6I/KjU5EtFMS5+vPS/BPLq8t6 z5ZQIK6GmJYQ8kMO9By+s+YiahLBGEFKsOxDjK7oW4VDcibMF3rlp1yi1BMaO36O MTDYW/JgP5N9ECJ+epc+sWw8LCozgFAlyO74xWQILEaXbrTMDm/HKda7t4aSiBZh gU5d6ZjZrda81L/RjLpurg93Z3of6tqiXUsCQ6rRaRx+n/jfheGKSMJDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=UA+VVCnGzkkNIuqKXObtavL8wxUG01U2iUsM9Tmlh44=; b=caGL0rwr QTwgyL5jhCAMOxGNcr8KEaL7jWOI6BQz5LY62eOBj1+d2dXWl00bW9XF/T4u8Hw/ ja0CGfzl/ELIpz4a6oOfQSrk9HGsVdr/HG3R6rHz4j0bN4/yjZt+Eh6R+56wbvHt j34w6Vumz2G3yB9Fn7fOZhHKjTxbMNG8mkzyisMQN41PxQ7iPr2S2k/JHHroZRS8 R2utYbgr9w+u9joQ3dVETptUH94iPutiz2sWhbpNV6+WuUfhuM7Tj5tsB8uYOaX/ QcM7p8+IxyJ+GqvxPmJl5EipxDovcDYMqmG8lwXZvjI1oWWyqjn039EM66yg8xpT j86OeiJr5h/2+g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddthedgudeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucfkphepkedtrdduieejrdelkedrudeltdenucevlhhushhtvghrufhiiigvpedune curfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id 99ADC3280395; Wed, 4 Nov 2020 05:22:52 -0500 (EST) From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH for-5.2 2/3] hw/block/nvme: fix uint16_t use of uint32_t sgls member Date: Wed, 4 Nov 2020 11:22:47 +0100 Message-Id: <20201104102248.32168-3-its@irrelevant.dk> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201104102248.32168-1-its@irrelevant.dk> References: <20201104102248.32168-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=64.147.123.21; envelope-from=its@irrelevant.dk; helo=wout5-smtp.messagingengine.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/04 05:22:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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: Kevin Wolf , Peter Maydell , qemu-block@nongnu.org, Dmitry Fomichev , Klaus Jensen , Max Reitz , Keith Busch , Minwoo Im , Klaus Jensen Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen nvme_map_sgl_data erroneously uses the sgls member of NvmeIdNs as a uint16_t. Reported-by: Coverity (CID 1436129) Fixes: cba0a8a344fe ("hw/block/nvme: add support for scatter gather lists") Signed-off-by: Klaus Jensen Reviewed-by: Max Reitz Reviewed-by: Philippe Mathieu-Daudé --- hw/block/nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 080d782f1c2b..2bdc50eb6fce 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -452,7 +452,7 @@ static uint16_t nvme_map_sgl_data(NvmeCtrl *n, QEMUSGList *qsg, * segments and/or descriptors. The controller might accept * ignoring the rest of the SGL. */ - uint16_t sgls = le16_to_cpu(n->id_ctrl.sgls); + uint32_t sgls = le32_to_cpu(n->id_ctrl.sgls); if (sgls & NVME_CTRL_SGLS_EXCESS_LENGTH) { break; }