Commit 87575437d8173c7da48a4dee25399807c7bec9cb
Committed by
Linus Torvalds
1 parent
56d611a04f
Exists in
master
and in
7 other branches
drivers/char/ppdev.c: use kasprintf
kasprintf combines kmalloc and sprintf, and takes care of the size calculation itself. The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a,flag; expression list args; statement S; @@ a = - \(kmalloc\|kzalloc\)(...,flag) + kasprintf(flag,args) <... when != a if (a == NULL || ...) S ...> - sprintf(a,args); // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Cc: Michael Buesch <mb@bu3sch.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 1 additions and 3 deletions Side-by-side Diff
drivers/char/ppdev.c
... | ... | @@ -287,11 +287,9 @@ |
287 | 287 | char *name; |
288 | 288 | int fl; |
289 | 289 | |
290 | - name = kmalloc (strlen (CHRDEV) + 3, GFP_KERNEL); | |
290 | + name = kasprintf(GFP_KERNEL, CHRDEV "%x", minor); | |
291 | 291 | if (name == NULL) |
292 | 292 | return -ENOMEM; |
293 | - | |
294 | - sprintf (name, CHRDEV "%x", minor); | |
295 | 293 | |
296 | 294 | port = parport_find_number (minor); |
297 | 295 | if (!port) { |