Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3092610pxj; Mon, 7 Jun 2021 01:58:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGnxG+SyvJOGo4+aFZUjhCpxVj1MxZ1Nz0zhK5E+jjU1KsViT0Pk5Pd40M/msSXPcqdSco X-Received: by 2002:a17:906:c241:: with SMTP id bl1mr16621070ejb.536.1623056316823; Mon, 07 Jun 2021 01:58:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623056316; cv=none; d=google.com; s=arc-20160816; b=J8fDnaBFhr/R2vbkixmLce74361NnUEC6ynlq4f+4ruszfltgVE29TlE9s1SFR0hkW OYsP3rKNtBk/eVFDj+8eaNN4ia3D+R0TANXr6KSrTpEDcoDN+b+Cs+6/SjjdmL37Bcjo yJX9PwdDIAyQT/LWp2dp4Kzu4nHC++DhYWk8QdyMww7nRd+815Xp3sfKEd9/5sy4l4bN MD5yzHXMYrdOp3JTmyxYC7WE0q02/TSy8Z2dgXmVP0Y4i5sEwz+CTuH/tYapYH1q7Afs 9IN/mT0+0lhl/EJ7Ox9/fchIed/KIOWmhX2dQfl8blHeq3qM5bYbbmgtk03GyVEw8tSp V7IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=70d+eeUNUJUrApqI9dcysM+A4Ouzv/oKGOxjeF7oXZo=; b=ZEk8TSYamrnKlQF0V9WCxfyHlFNcLirgcDQXIpe1fRPiKVKflvJsnvHHTKFcU6nSuk 8e2hqjgGYvBDAIkQIKX5xPJDCfiTQdQboS1KZdiioXzW4FQGHl4UW0TE8nhIhf7W4hhF BFJpGVF78jLdH7B4J+eEViJ0Ro5/tKDXdBA6T4yggmB//dOEil2pBFCJ0KoyeFjHyj90 p5L8J1yODYR+kYPxI6QUsB7GnZ+cc/Np3muAZZK3WBNcZbcHD2/ET3zKm2ftMFOJK7qd qArCalMWI1N5Jzeto3RqPM0DOfk2jsj3HmRQScY8Dbzl1mnY0Rzxcuc9ZlebmN6xTDHw fXwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jWgCRi59; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=3IYcJthl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si11695547ejy.722.2021.06.07.01.58.14; Mon, 07 Jun 2021 01:58:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jWgCRi59; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=3IYcJthl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbhFGI7H (ORCPT + 99 others); Mon, 7 Jun 2021 04:59:07 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:49222 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbhFGI7E (ORCPT ); Mon, 7 Jun 2021 04:59:04 -0400 Received: from relay2.suse.de (unknown [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 297F121A5B; Mon, 7 Jun 2021 08:57:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1623056232; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=70d+eeUNUJUrApqI9dcysM+A4Ouzv/oKGOxjeF7oXZo=; b=jWgCRi59aEiHaDvW/KVX0XjMm20RZwopSJiDit2t46cZbiXznJ7t3XhxHg+bVH6jNAvcgx 40W103nVzIqtB2LfpOTYG3unnCnkURo3c/+YO8DiacHJq+16wXhRvEOgIgcw8WtWYo7OKY PO8PcLSbzcdg9m34g4vfGGUrUvhJIk0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1623056232; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=70d+eeUNUJUrApqI9dcysM+A4Ouzv/oKGOxjeF7oXZo=; b=3IYcJthl7lzsUQ9np6thDiH1QtqT+G3oQEEA3Bxv63MhPO96ocbjjSbhCRaBjTHFGnoGju lIXfTDc0b8pm29BQ== Received: from adalid.arch.suse.de (adalid.arch.suse.de [10.161.8.13]) by relay2.suse.de (Postfix) with ESMTP id EC4C4A3B83; Mon, 7 Jun 2021 08:57:11 +0000 (UTC) Received: by adalid.arch.suse.de (Postfix, from userid 17828) id DF693516FDED; Mon, 7 Jun 2021 10:57:11 +0200 (CEST) From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Daniel Wagner , Hannes Reinecke , Chaitanya Kulkarni Subject: [PATCH v2] nvme: verify MNAN value if ANA is enabled Date: Mon, 7 Jun 2021 10:56:56 +0200 Message-Id: <20210607085656.101772-1-dwagner@suse.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The controller is required to have a non-zero MNAN value if it supports ANA: If the controller supports Asymmetric Namespace Access Reporting, then this field shall be set to a non-zero value that is less than or equal to the NN value. Reviewed-by: Hannes Reinecke Reviewed-by: Chaitanya Kulkarni Signed-off-by: Daniel Wagner --- v2: - moved the check to nvme_mpath_init_identify - added reviewed tags drivers/nvme/host/multipath.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index a501917d4c6e..23573fe3fc7d 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -813,6 +813,13 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) !(ctrl->subsys->cmic & NVME_CTRL_CMIC_ANA)) return 0; + if (!ctrl->max_namespaces || + ctrl->max_namespaces > le32_to_cpu(id->nn)) { + dev_err(ctrl->device, + "Invalid MNAN value %u\n", ctrl->max_namespaces); + return -EINVAL; + } + ctrl->anacap = id->anacap; ctrl->anatt = id->anatt; ctrl->nanagrpid = le32_to_cpu(id->nanagrpid); -- 2.29.2