lkdtm/fortify: Check for NULL return of kmalloc()
Subsystems (2)
PATCH 1/1 lkdtm/fortify: Check for NULL return of kmalloc()
The memory allocation function kmalloc() may return a NULL pointer. If 'src' is NULL, the strscpy() would copy the string to a NULL address.
Therefore, it is better to check the return value of kmalloc() to avoid the confusion.
Signed-off-by QintaoShen <[email protected]>
--- drivers/misc/lkdtm/fortify.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/lkdtm/fortify.c +3 -0
@@ -41,6 +41,9 @@ void lkdtm_FORTIFIED_SUBOBJECT(void)char *src; src =kmalloc (size,GFP_KERNEL ); +if (!src) +return ; +strscpy (src,"over ten bytes" , size); size =strlen (src) +1 ;
Signature · 1 line
2.7.4