lkml.org 
[lkml]   [2022]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] lkdtm/perms: Check possible NULL pointer returned by kmalloc(),vmalloc()
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

\
 
 \ /
  Last update: 2022-07-25 10:43    [W:0.087 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site