From: Jarkko Sakkinen <jarkko@kernel.org>
To: Yang Yingliang <yangyingliang@huawei.com>
Cc: linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org, jejb@linux.ibm.com
Subject: Re: [PATCH -next] KEYS: trusted: Switch to kmemdup_nul()
Date: Sun, 4 Apr 2021 19:01:06 +0300 [thread overview]
Message-ID: <YGniwpyGNPLvn3Mf@kernel.org> (raw)
In-Reply-To: <20210402092346.2444932-1-yangyingliang@huawei.com>
On Fri, Apr 02, 2021 at 05:23:46PM +0800, Yang Yingliang wrote:
> Use kmemdup_nul() helper instead of open-coding to
> simplify the code.
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
> security/keys/trusted-keys/trusted_tpm1.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
/Jarkko
>
> diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trusted-keys/trusted_tpm1.c
> index 493eb91ed017..90ded4757e79 100644
> --- a/security/keys/trusted-keys/trusted_tpm1.c
> +++ b/security/keys/trusted-keys/trusted_tpm1.c
> @@ -978,11 +978,9 @@ static int trusted_instantiate(struct key *key,
> if (datalen <= 0 || datalen > 32767 || !prep->data)
> return -EINVAL;
>
> - datablob = kmalloc(datalen + 1, GFP_KERNEL);
> + datablob = kmemdup_nul(prep->data, datalen, GFP_KERNEL);
> if (!datablob)
> return -ENOMEM;
> - memcpy(datablob, prep->data, datalen);
> - datablob[datalen] = '\0';
>
> options = trusted_options_alloc();
> if (!options) {
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2021-04-04 16:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-02 9:23 [PATCH -next] KEYS: trusted: Switch to kmemdup_nul() Yang Yingliang
2021-04-04 16:01 ` Jarkko Sakkinen [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-04-12 16:00 Wei Yongjun
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=YGniwpyGNPLvn3Mf@kernel.org \
--to=jarkko@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=yangyingliang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.