public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/parser.c: switch match_strdup() over to use kmemdup_nul()
Date: Thu, 30 Aug 2018 16:19:31 -0700	[thread overview]
Message-ID: <20180830161931.ce995be9e83fd43382f49bee@linux-foundation.org> (raw)
In-Reply-To: <20180830194436.188867-1-ebiggers@kernel.org>

On Thu, 30 Aug 2018 12:44:36 -0700 Eric Biggers <ebiggers@kernel.org> wrote:

> From: Eric Biggers <ebiggers@google.com>
> 
> This simplifies the code.  No change in behavior.
> 
> ...
>
> --- a/lib/parser.c
> +++ b/lib/parser.c
> @@ -327,10 +327,6 @@ EXPORT_SYMBOL(match_strlcpy);
>   */
>  char *match_strdup(const substring_t *s)
>  {
> -	size_t sz = s->to - s->from + 1;
> -	char *p = kmalloc(sz, GFP_KERNEL);
> -	if (p)
> -		match_strlcpy(p, s, sz);
> -	return p;
> +	return kmemdup_nul(s->from, s->to - s->from, GFP_KERNEL);
>  }
>  EXPORT_SYMBOL(match_strdup);

Huh.  I never noticed kmemdup_nul() fly past - it rather happened on
the sly.  We do have some fun goodies in there.

We could make match_strdup() an inline now.  But that will probably
produce a fatter kernel, as each callsite would then need to prepare
three args rather than one.


      reply	other threads:[~2018-08-30 23:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30 19:44 [PATCH] lib/parser.c: switch match_strdup() over to use kmemdup_nul() Eric Biggers
2018-08-30 23:19 ` Andrew Morton [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=20180830161931.ce995be9e83fd43382f49bee@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ebiggers@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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