lkml.org 
[lkml]   [2022]   [Jul]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/3] lkdtm/perms: Check possible NULL pointer returned by kmalloc(),vmalloc()
From
Date
When there is insufficient memory, the allocation will fail.

the return value is void,so i think it is ok .

should i have changed comment to something like this ?

As the possible alloc failure of the kmalloc() and vmalloc(),
the return pointer could be NULL.therefore it should be better to check it.


在 2022年07月25日 16:42, Greg KH 写道:
> 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 11:54    [W:0.094 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site