From: Greg Kroah-Hartman usb_free_urb() can take a NULL, so let's check and warn about that. Signed-off-by: Greg Kroah-Hartman Signed-off-by: Andy Whitcroft Signed-off-by: Andrew Morton --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN scripts/checkpatch.pl~checkpatch-usb_free_urb-can-take-null scripts/checkpatch.pl --- a/scripts/checkpatch.pl~checkpatch-usb_free_urb-can-take-null +++ a/scripts/checkpatch.pl @@ -2078,6 +2078,13 @@ sub process { WARN("kfree(NULL) is safe this check is probabally not required\n" . $hereprev); } } +# check for needless usb_free_urb() checks + if ($prevline =~ /\bif\s*\(([^\)]*)\)/) { + my $expr = $1; + if ($line =~ /\busb_free_urb\(\Q$expr\E\);/) { + WARN("usb_free_urb(NULL) is safe this check is probably not required\n" . $hereprev); + } + } # warn about #ifdefs in C files # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { _