aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/au1100fb.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-09-22 19:47:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-09-23 10:39:56 -0400
commitff8147fe71246b81a48de5f37041b026b57d60ca (patch)
tree9ae6fb50b937d1b38a7d53a925d5fb9759db1cd4 /drivers/video/au1100fb.c
parentf7a595e98c3140f1271957aa742a6b84407620d4 (diff)
drivers/video: add kmalloc NULL tests
Check that the result of kmalloc is not NULL before passing it to other functions. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @@ expression *x; identifier f; constant char *C; @@ x = \(kmalloc\|kcalloc\|kzalloc\)(...); ... when != x == NULL when != x != NULL when != (x || ...) ( kfree(x) | f(...,C,...,x,...) | *f(...,x,...) | *x->f ) // </smpl> [akpm@linux-foundation.org: convert to kstrdup() as well] Signed-off-by: Julia Lawall <julia@diku.dk> Cc: Ming Lei <tom.leiming@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/au1100fb.c')
-rw-r--r--drivers/video/au1100fb.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/video/au1100fb.c b/drivers/video/au1100fb.c
index 378f27745a1d..a699aab63820 100644
--- a/drivers/video/au1100fb.c
+++ b/drivers/video/au1100fb.c
@@ -715,8 +715,11 @@ int au1100fb_setup(char *options)
715 } 715 }
716 /* Mode option (only option that start with digit) */ 716 /* Mode option (only option that start with digit) */
717 else if (isdigit(this_opt[0])) { 717 else if (isdigit(this_opt[0])) {
718 mode = kmalloc(strlen(this_opt) + 1, GFP_KERNEL); 718 mode = kstrdup(this_opt, GFP_KERNEL);
719 strncpy(mode, this_opt, strlen(this_opt) + 1); 719 if (!mode) {
720 print_err("memory allocation failed");
721 return -ENOMEM;
722 }
720 } 723 }
721 /* Unsupported option */ 724 /* Unsupported option */
722 else { 725 else {