Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp572272imm; Wed, 1 Aug 2018 01:26:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdQkElsalShnliQ/cO4nA862SCHuyOXIqlqvsg57oGhetD2Uprw8OY1QCDNFXoDEtDsLofR X-Received: by 2002:a62:4f5b:: with SMTP id d88-v6mr25828805pfb.225.1533111993434; Wed, 01 Aug 2018 01:26:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533111993; cv=none; d=google.com; s=arc-20160816; b=zgGi6Uu+FW6vxxwUF7AnTnyaTKwhgGGub/4mz9sGWuO3WEJG9NhuRgI9ln33b4W4JN G7oYI07vXJupdR8a3H+ouGYKO27X/ZkYOZfnq6QohKqCAJ2EUibSwmHIGkCLKgkRtF+x YkP3YB3/yCRFk/J2rmjlu9N2ruXIgQhVDh/b5Qzd6bXeA0OvhKvOpz114g82FAcm9bDJ l2RduC61XoAfquhK8uSi0CnPJmWScXb5ToakFuQpbZLcRzBwJNcXAZfCKgxBc28zrABb /yBqFamPsRMFWr6oGMbx7vaSZPDyb+l88ksBJZFE87ffiucB34CNSMqBxTlJ9Fi0dZij 1SYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=f+SL9uvJNEWg+popDid4p1Jh8tdKQMs4rkoLeGnrV6M=; b=yPUYCY8e6Znd7BOWsLqJj02CMYWR9Wivf5ruUHl/6EqYtvK992EKGdsxEXbIxN2MkN 4SyQkL9T9rVPXK9gZGk9yS03JQVY4hTqGIMxyinwdgfVhg/eqOocPRLHGUffFa1JpajP VG+UZhk2Y8GShGOBeDwiG/HNPJgJi46hViNRzl/uKO3eyJgmqGjTlvNoq/p0D9YCjLdq itN5y4LyS/eEJY3/Arued6llrIehRjIyb4iaPdr9E6b0LadQEr591zPJ6erskBCGB5ec JwPGpPzfSt8xfWsZzWBsiCVdLWhlGfT0gBQX+xVk8bPjp/cOHj4iQOQmjf11hO6q1Gh3 O/uw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x62-v6si15612427pfa.80.2018.08.01.01.26.19; Wed, 01 Aug 2018 01:26:33 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388659AbeHAKJy (ORCPT + 99 others); Wed, 1 Aug 2018 06:09:54 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60782 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387699AbeHAKJx (ORCPT ); Wed, 1 Aug 2018 06:09:53 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C9F94D586D2F1; Wed, 1 Aug 2018 16:25:11 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.399.0; Wed, 1 Aug 2018 16:25:07 +0800 Subject: Re: [PATCH] net/9p/trans_virtio.c: add a terminal char for mount tag To: Dominique Martinet References: <5B6164F6.60004@huawei.com> <20180801081157.GA20127@nautica> CC: "akpm@linux-foundation.org" , "Linux Kernel Mailing List" , , Greg Kurz From: piaojun Message-ID: <5B616E3B.4050205@huawei.com> Date: Wed, 1 Aug 2018 16:24:27 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20180801081157.GA20127@nautica> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dominique, On 2018/8/1 16:11, Dominique Martinet wrote: > piaojun wrote on Wed, Aug 01, 2018: >> chan->tag has no terminal char at last which will result in printing messy >> code when debugging code. So we should add '\0' for tag. > > 9p is full of non null-terminated string so I'm not sure how I feel > about it, is there anything wrong with how this is used or was this just > when you tried to printf it? There is nothing wrong at the places using tag, as they calculated the tag_len carefully. Adding '\0' for it will make the code more robust. And I'm glad to hear others' opinions. Thanks, Jun > > If it's just for debugging I'd suggest using the printf format "%.*s" > with "chan->tag_len, chan->tag" arguments, > > > That said it's not like this is costly, so I'll take it if someone else > thinks this is helpful > >> >> Signed-off-by: Jun Piao >> --- >> net/9p/trans_virtio.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c >> index d422bfc..49d71d6 100644 >> --- a/net/9p/trans_virtio.c >> +++ b/net/9p/trans_virtio.c >> @@ -585,7 +585,7 @@ static int p9_virtio_probe(struct virtio_device *vdev) >> err = -EINVAL; >> goto out_free_vq; >> } >> - tag = kmalloc(tag_len, GFP_KERNEL); >> + tag = kzalloc(tag_len + 1, GFP_KERNEL); >> if (!tag) { >> err = -ENOMEM; >> goto out_free_vq; >> --