From: Dave Jiang <dave.jiang@intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Ross Zwisler <ross.zwisler@linux.intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
linux-nvdimm@lists.01.org
Subject: Re: [PATCH v1] libnvdimm, namespace: Replace kmemdup() with kstrndup()
Date: Thu, 30 Aug 2018 15:05:49 -0700 [thread overview]
Message-ID: <37b9f2e8-9612-c0e6-6466-63301372c025@intel.com> (raw)
In-Reply-To: <20180830115610.GN11447@smile.fi.intel.com>
On 08/30/2018 04:56 AM, Andy Shevchenko wrote:
> On Mon, Jun 11, 2018 at 04:47:21PM +0300, Andy Shevchenko wrote:
>> kstrndup() takes care of '\0' terminator for the strings.
>>
>> Use it here instead of kmemdup() + explicit terminating the input string.
>>
>
> Any comments on this?
Applied. Sorry looks like this one got missed.
>
>> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> ---
>> drivers/nvdimm/namespace_devs.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
>> index 28afdd668905..19525f025539 100644
>> --- a/drivers/nvdimm/namespace_devs.c
>> +++ b/drivers/nvdimm/namespace_devs.c
>> @@ -270,11 +270,10 @@ static ssize_t __alt_name_store(struct device *dev, const char *buf,
>> if (dev->driver || to_ndns(dev)->claim)
>> return -EBUSY;
>>
>> - input = kmemdup(buf, len + 1, GFP_KERNEL);
>> + input = kstrndup(buf, len, GFP_KERNEL);
>> if (!input)
>> return -ENOMEM;
>>
>> - input[len] = '\0';
>> pos = strim(input);
>> if (strlen(pos) + 1 > NSLABEL_NAME_LEN) {
>> rc = -EINVAL;
>> --
>> 2.17.1
>>
>
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
prev parent reply other threads:[~2018-08-30 22:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 13:47 [PATCH v1] libnvdimm, namespace: Replace kmemdup() with kstrndup() Andy Shevchenko
2018-08-30 11:56 ` Andy Shevchenko
2018-08-30 22:05 ` Dave Jiang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=37b9f2e8-9612-c0e6-6466-63301372c025@intel.com \
--to=dave.jiang@intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=linux-nvdimm@lists.01.org \
--cc=ross.zwisler@linux.intel.com \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).