public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Ren Yu <renyu@nfschina.com>
Cc: keescook@chromium.org, arnd@arndb.de,
	linux-kernel@vger.kernel.org, liqiong@nfschina.com,
	yuzhe@nfschina.com
Subject: Re: [PATCH 2/3] lkdtm/perms: Check possible NULL pointer returned by kmalloc(),vmalloc()
Date: Mon, 25 Jul 2022 10:42:12 +0200	[thread overview]
Message-ID: <Yt5XZN3CdTprfjwk@kroah.com> (raw)
In-Reply-To: <20220725081153.20228-1-renyu@nfschina.com>

On Mon, Jul 25, 2022 at 04:11:53PM +0800, Ren Yu wrote:
> As the possible alloc failure of the kmalloc() and vmalloc(),the
> return pointer could be NULL.therefore it should be better to check it.
> 
> Signed-off-by: Ren Yu <renyu@nfschina.com>
> ---
>  drivers/misc/lkdtm/perms.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
> index b93404d65650..34b43b9ea1f1 100644
> --- a/drivers/misc/lkdtm/perms.c
> +++ b/drivers/misc/lkdtm/perms.c
> @@ -180,6 +180,9 @@ static void lkdtm_EXEC_STACK(void)
>  static void lkdtm_EXEC_KMALLOC(void)
>  {
>  	u32 *kmalloc_area = kmalloc(EXEC_SIZE, GFP_KERNEL);
> +	if (!kmalloc_area)
> +		return;
> +

Always run checkpatch on your patches so that grumpy maintainers do not
have to tell you to run checkpatch on your patches...

Also, shouldn't this return an error?

But most importantly, how can this ever fail?

thanks,

greg k-h

  reply	other threads:[~2022-07-25  8:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  8:11 [PATCH 2/3] lkdtm/perms: Check possible NULL pointer returned by kmalloc(),vmalloc() Ren Yu
2022-07-25  8:42 ` Greg KH [this message]
2022-07-25  9:54   ` tury
2022-07-25 12:37     ` Greg KH
2022-07-26  5:43       ` tury
2022-07-27 21:00         ` Kees Cook

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=Yt5XZN3CdTprfjwk@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liqiong@nfschina.com \
    --cc=renyu@nfschina.com \
    --cc=yuzhe@nfschina.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