Commit 5ce59ae0 authored by Joe Perches's avatar Joe Perches Committed by Linus Torvalds
Browse files

checkpatch: Add check for kcalloc argument order

kcalloc is sometimes misused with the first and second arguments switched.

Same issue with kmalloc_array too.

Bleat if sizeof is the first argument
Signed-off-by: default avatarJoe Perches <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent e8eb3997
......@@ -3476,6 +3476,12 @@ sub process {
"unnecessary cast may hide bugs, see\n" . $herecurr);
# check for alloc argument mismatch
if ($line =~ /\b(kcalloc|kmalloc_array)\s*\(\s*sizeof\b/) {
"$1 uses number as first arg, sizeof is generally wrong\n" . $herecurr);
# check for multiple semicolons
if ($line =~ /;\s*;\s*$/) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment