Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965757AbdGTPwc (ORCPT ); Thu, 20 Jul 2017 11:52:32 -0400 Received: from smtprelay0054.hostedemail.com ([216.40.44.54]:43510 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965731AbdGTPwT (ORCPT ); Thu, 20 Jul 2017 11:52:19 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::,RULES_HIT:41:305:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3865:3867:3870:4321:4605:5007:6142:6143:10004:10400:10848:11232:11658:11914:12048:12296:12740:12760:12895:13069:13311:13357:13439:14181:14659:14721:21080:21451:21627:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:3,LUA_SUMMARY:none X-HE-Tag: skin95_884c38c2fc824 X-Filterd-Recvd-Size: 2174 Message-ID: <1500565934.14415.12.camel@perches.com> Subject: Re: [PATCH v2 3/3] nvme: wwid_show: strip trailing 0-bytes From: Joe Perches To: Martin Wilck , Christoph Hellwig , Keith Busch , Sagi Grimberg Cc: Martin Wilck , Johannes Thumshirn , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Date: Thu, 20 Jul 2017 08:52:14 -0700 In-Reply-To: <20170720152745.3274-4-mwilck@suse.com> References: <20170720152745.3274-1-mwilck@suse.com> <20170720152745.3274-4-mwilck@suse.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.22.6-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1155 Lines: 30 On Thu, 2017-07-20 at 17:27 +0200, Martin Wilck wrote: > Some broken targets (such as the current Linux target) pad > model or serial fields with 0-bytes rather than spaces. The > NVME spec disallows 0 bytes in "ASCII" fields. > Thus strip trailing 0-bytes, too. > > Signed-off-by: Martin Wilck > Reviewed-by: Hannes Reinecke > Acked-by: Christoph Hellwig > > --- > drivers/nvme/host/core.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c [] > @@ -2001,9 +2001,11 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr, > if (memchr_inv(ns->eui, 0, sizeof(ns->eui))) > return sprintf(buf, "eui.%8phN\n", ns->eui); > > - while (ctrl->serial[serial_len - 1] == ' ') > + while (ctrl->serial[serial_len - 1] == ' ' || > + ctrl->serial[serial_len - 1] == '\0') > serial_len--; > - while (ctrl->model[model_len - 1] == ' ') > + while (ctrl->model[model_len - 1] == ' ' || > + ctrl->model[model_len - 1] == '\0') > model_len--; Please add a _len > 0 to the while loops too