Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1963444ima; Thu, 25 Oct 2018 07:38:58 -0700 (PDT) X-Google-Smtp-Source: AJdET5eyCoanECRYOb/V2uwJYdpXlCwJUaYr7Rb6JwLlJgxyJdSy6OX7V1DQNSZHMMvxMH1ALG8D X-Received: by 2002:a17:902:bd4a:: with SMTP id b10-v6mr1738927plx.171.1540478338291; Thu, 25 Oct 2018 07:38:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478338; cv=none; d=google.com; s=arc-20160816; b=o+C+oNE2rnZRQzwCyTI+K+M8gN1RMQkcicWFAnfCs7BQHMtC2AhnMFvRk1Cv5Er2kQ Lf/1LQwpvtml6LHnZnTwWHmNQwOJ0wZ6KkxMupWXrA2H12sVkO370Vpsp9oxnFu4JJMi F3NGKI4ErZkLGHXPwBWr597S8QfRitILCWSh2Kz3GX7WJxEKH6SKUvfusi1Kw4k7MbtV T6m3/dsljUxs0MStppkst0oU9BPWsLT9x3mW5M+QIFO7hRqce18ookvzmyzeRnv2godA gGoI7QRk2Yn+sV/il9AXL8LHF5z7Mfu9piVtHre4rDo6OFYqSq0ul3B8v5aqFpGVBVQ5 kAgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=S34I9SUAJaHni2tojatZ2I9p/Hl3aLQYRre5UKA3ojo=; b=ntUfhe+k8dA/o+EfukE41ipGufq2Y5J+CLZgjg7MdwKZi+AgFJClzT36NzwEnFvooT rPGNNrDmqdPnWmZN4lon/E6qEmo+DBE/z99i6pZjSIOInId7GZ6w14qZ3PdYffaEzF8b TlNmitM9ED37jv/oh28rBtYdzgNv6RaIzyxQdx6RWIztK5wcqBxmXK/81mkibI06HcHk sftQiOSpOwrOUZ5pXe0N6HQZcHV/Fq30FgMyvk5YUYeSSJJ7HEhSu4Tj2fa2IPqjhkMF CC3S1wH0vksmKJnSxPHRbZmxmx+z9TaKSvYFMCJ/ejHFMRCr00frmAVyW2ddEn/0A7pN GSjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=diTlvgYp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e14-v6si7908246pgb.254.2018.10.25.07.38.14; Thu, 25 Oct 2018 07:38:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=diTlvgYp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729463AbeJYWtg (ORCPT + 99 others); Thu, 25 Oct 2018 18:49:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:58820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728100AbeJYWtf (ORCPT ); Thu, 25 Oct 2018 18:49:35 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C187620854; Thu, 25 Oct 2018 14:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476998; bh=Nsmgz6XxhKXhN9rpJNfF4K36+lf5owguKdSnlli4EMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=diTlvgYpCJdQoK+hlMYn6LlLUUwaUa0GR/UN0Zc1x3BahPxEoUbWaJF6T0casNMd/ Sh3/oMAb7Mk18fOE1K5SwD0XNdBxWTrPaSEpWxD+lKSkztt/C3yqS6GwtvH8txnRJd 1rNjMuwAYBZeeBG9h1laA04zaEsAxPDk5qktUijM= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Verkamp , Keith Busch , Jens Axboe , Sasha Levin Subject: [PATCH AUTOSEL 4.9 92/98] nvmet: fix space padding in serial number Date: Thu, 25 Oct 2018 10:14:17 -0400 Message-Id: <20181025141423.213774-92-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Verkamp [ Upstream commit c73996984902516745bc587d5e8a0b2e034aea05 ] Commit 42de82a8b544 previously attempted to fix this, and it did correctly pad the MN and FR fields with spaces, but the SN field still contains 0 bytes. The current code fills out the first 16 bytes with hex2bin, leaving the last 4 bytes zeroed. Rather than adding a lot of error-prone math to avoid overwriting SN twice, just set the whole thing to spaces up front (it's only 20 bytes). Fixes: 42de82a8b544 ("nvmet: don't report 0-bytes in serial number") Signed-off-by: Daniel Verkamp Reviewed-by: Martin Wilck Signed-off-by: Keith Busch Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/nvme/target/admin-cmd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c index 2caed285fd7b..cdb7752dcbb7 100644 --- a/drivers/nvme/target/admin-cmd.c +++ b/drivers/nvme/target/admin-cmd.c @@ -192,6 +192,7 @@ static void nvmet_execute_identify_ctrl(struct nvmet_req *req) id->vid = 0; id->ssvid = 0; + memset(id->sn, ' ', sizeof(id->sn)); bin2hex(id->sn, &ctrl->subsys->serial, min(sizeof(ctrl->subsys->serial), sizeof(id->sn) / 2)); copy_and_pad(id->mn, sizeof(id->mn), model, sizeof(model) - 1); -- 2.17.1