fortify: Increase pointer assignment check
Commit Message
Increase the check after the src pointer allocates memory. If these two
functions are used, at least increase some robustness.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
drivers/misc/lkdtm/fortify.c | 6 ++++++
1 file changed, 6 insertions(+)
@@ -44,6 +44,9 @@ static void lkdtm_FORTIFY_STR_MEMBER(void)
char *src;
src = kmalloc(size, GFP_KERNEL);
+ if (src == NULL)
+ return;
+
strscpy(src, "over ten bytes", size);
size = strlen(src) + 1;
@@ -109,6 +112,9 @@ static void lkdtm_FORTIFY_MEM_MEMBER(void)
char *src;
src = kmalloc(size, GFP_KERNEL);
+ if (src == NULL)
+ return;
+
strscpy(src, "over ten bytes", size);
size = strlen(src) + 1;