Commit Graph

2147 Commits

Author SHA1 Message Date
Robin Jarry 00cffbf482 kbuild: use HOSTLDFLAGS for single .c executables
When compiling executables from a single .c file, the linker is also
invoked. Pass the HOSTLDFLAGS like for other linker commands.

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Change-Id: I8332132775e7cc220eb7d1e20911223bca65e1e2
2023-03-24 20:12:56 +01:00
Manuel Traut 6b3bf104df scripts/decode_stacktrace.sh: prefix addr2line with $CROSS_COMPILE
[ Upstream commit c04e32e911653442fc834be6e92e072aeebe01a1 ]

At least for ARM64 kernels compiled with the crosstoolchain from
Debian/stretch or with the toolchain from kernel.org the line number is
not decoded correctly by 'decode_stacktrace.sh':

  $ echo "[  136.513051]  f1+0x0/0xc [kcrash]" | \
    CROSS_COMPILE=/opt/gcc-8.1.0-nolibc/aarch64-linux/bin/aarch64-linux- \
   ./scripts/decode_stacktrace.sh /scratch/linux-arm64/vmlinux \
                                  /scratch/linux-arm64 \
                                  /nfs/debian/lib/modules/4.20.0-devel
  [  136.513051] f1 (/linux/drivers/staging/kcrash/kcrash.c:68) kcrash

If addr2line from the toolchain is used the decoded line number is correct:

  [  136.513051] f1 (/linux/drivers/staging/kcrash/kcrash.c:57) kcrash

Link: http://lkml.kernel.org/r/20190527083425.3763-1-manut@linutronix.de
Signed-off-by: Manuel Traut <manut@linutronix.de>
Acked-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Change-Id: I71d5204ee59336f4091601e726a5930b7bdf0662
2020-11-30 19:35:40 +03:00
Marc Zyngier 6f2790d2ec scripts/decode_stacktrace: only strip base path when a prefix of the path
[ Upstream commit 67a28de47faa83585dd644bd4c31e5a1d9346c50 ]

Running something like:

	decodecode vmlinux .

leads to interested results where not only the leading "." gets stripped
from the displayed paths, but also anywhere in the string, displaying
something like:

	kvm_vcpu_check_block (arch/arm64/kvm/virt/kvm/kvm_mainc:2141)

which doesn't help further processing.

Fix it by only stripping the base path if it is a prefix of the path.

Link: http://lkml.kernel.org/r/20181210174659.31054-3-marc.zyngier@arm.com
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Change-Id: I3cb23106d284450f441e7ffb352cd7d05ec1dee4
2020-11-30 19:35:37 +03:00
Josh Poimboeuf c2cbbac2c8 scripts/decode_stacktrace.sh: Fix address line detection on x86
Kirill reported that the decode_stacktrace.sh script was broken by the
following commit:

  bb5e5ce545f2 ("x86/dumpstack: Remove kernel text addresses from stack dump")

Fix it by updating the per-line absolute address check to also check for
function-based address lines like the following:

  write_sysrq_trigger+0x51/0x60

I didn't remove the check for absolute addresses because it's still
needed for ARM.

Reported-by: Kirill A. Shutemov <kirill@shutemov.name>
Tested-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sasha Levin <alexander.levin@verizon.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Fixes: bb5e5ce545f2 ("x86/dumpstack: Remove kernel text addresses from stack dump")
Link: http://lkml.kernel.org/r/20161128230635.4n2ofgawltgexgcg@treble
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Change-Id: Ic716321f593f8ae5766c7248352b27ddc792e438
2020-11-30 19:35:34 +03:00
Konstantin Khlebnikov a0a9ae3d70 scripts/decode_stacktrace.sh: handle symbols in modules
scripts/decode_stacktrace.sh presently displays module symbols as

	func+0x0ff/0x5153 [module]

Add a third argument: the pathname of a directory where the script
should look for the file module.ko so that the output appears as

	func (foo/bar.c:123) module

Without the argument or if the module file isn't found the script prints
such symbols as is without decoding.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: I73a3cafcb3846c7a08bc75972f188d116fb55edf
2020-11-30 19:35:31 +03:00
Robert Jarzmik 8773a314d6 scripts: decode_stacktrace: fix ARM architecture decoding
Fix the stack decoder for the ARM architecture.
An ARM stack is designed as :

[   81.547704] [<c023eb04>] (bucket_find_contain) from [<c023ec88>] (check_sync+0x40/0x4f8)
[   81.559668] [<c023ec88>] (check_sync) from [<c023f8c4>] (debug_dma_sync_sg_for_cpu+0x128/0x194)
[   81.571583] [<c023f8c4>] (debug_dma_sync_sg_for_cpu) from [<c0327dec>] (__videobuf_s

The current script doesn't expect the symbols to be bound by
parenthesis, and triggers the following errors :

  awk: cmd. line:1: error: Unmatched ( or \(: / (check_sync$/
  [   81.547704] (bucket_find_contain) from (check_sync+0x40/0x4f8)

Fix it by chopping starting and ending parenthesis from the each symbol
name.

As a side note, this probably comes from the function
dump_backtrace_entry(), which is implemented differently for each
architecture.  That makes a single decoding script a bit a challenge.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: Id056e494eb41a5c8740d9ce39dd959bca9590bfb
2020-11-30 19:35:28 +03:00
Sasha Levin 61223bca80 decode_stacktrace: make stack dump output useful again
Right now when people try to report issues in the kernel they send stack
dumps to eachother, which looks something like this:

  [    6.906437]  [<ffffffff811f0e90>] ? backtrace_test_irq_callback+0x20/0x20
  [    6.907121]  [<ffffffff84388ce8>] dump_stack+0x52/0x7f
  [    6.907640]  [<ffffffff811f0ec8>] backtrace_regression_test+0x38/0x110
  [    6.908281]  [<ffffffff813596a0>] ? proc_create_data+0xa0/0xd0
  [    6.908870]  [<ffffffff870a8040>] ? proc_modules_init+0x22/0x22
  [    6.909480]  [<ffffffff810020c2>] do_one_initcall+0xc2/0x1e0
  [...]

However, most of the text you get is pure garbage.

The only useful thing above is the function name.  Due to the amount of
different kernel code versions and various configurations being used,
the kernel address and the offset into the function are not really
helpful in determining where the problem actually occured.

Too often the result of someone looking at a stack dump is asking the
person who sent it for a translation for one or more 'addr2line'
translations.  Which slows down the entire process of debugging the
issue (and really annoying).

The decode_stacktrace script is an attempt to make the output more
useful and easy to work with by translating all kernel addresses in the
stack dump into line numbers.  Which means that the stack dump would
look like this:

  [  635.148361]  dump_stack (lib/dump_stack.c:52)
  [  635.149127]  warn_slowpath_common (kernel/panic.c:418)
  [  635.150214]  warn_slowpath_null (kernel/panic.c:453)
  [  635.151031]  _oalloc_pages_slowpath+0x6a/0x7d0
  [  635.152171]  ? zone_watermark_ok (mm/page_alloc.c:1728)
  [  635.152988]  ? get_page_from_freelist (mm/page_alloc.c:1939)
  [  635.154766]  __alloc_pages_nodemask (mm/page_alloc.c:2766)

It's pretty obvious why this is better than the previous stack dump
before.

Usage is pretty simple:

        ./decode_stacktrace.sh [vmlinux] [base path]

Where vmlinux is the vmlinux to extract line numbers from and base path
is the path that points to the root of the build tree, for example:

        ./decode_stacktrace.sh vmlinux /home/sasha/linux/ < input.log > output.log

The stack trace should be piped through it (I, for example, just pipe
the output of the serial console of my KVM test box through it).

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: Ibd1b079d54d49b081a72f44136c3b6c478523fbb
2020-11-30 19:35:25 +03:00
Artem Borisov d7992e6feb Merge remote-tracking branch 'stable/linux-3.4.y' into lineage-15.1
All bluetooth-related changes were omitted because of our ancient incompatible bt stack.

Change-Id: I96440b7be9342a9c1adc9476066272b827776e64
2017-12-27 17:13:15 +03:00
Colin Ian King 626c6e6e6f ftrace/scripts: Fix incorrect use of sprintf in recordmcount
commit 713a3e4de707fab49d5aa4bceb77db1058572a7b upstream.

Fix build warning:

scripts/recordmcount.c:589:4: warning: format not a string
literal and no format arguments [-Wformat-security]
    sprintf("%s: failed\n", file);

Fixes: a50bd43935586 ("ftrace/scripts: Have recordmcount copy the object file")
Link: http://lkml.kernel.org/r/1451516801-16951-1-git-send-email-colin.king@canonical.com

Cc: Li Bin <huawei.libin@huawei.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2016-10-26 23:15:42 +08:00
Steven Rostedt (Red Hat) 334e907923 ftrace/scripts: Have recordmcount copy the object file
commit a50bd43935586420fb75f4558369eb08566fac5e upstream.

Russell King found that he had weird side effects when compiling the kernel
with hard linked ccache. The reason was that recordmcount modified the
kernel in place via mmap, and when a file gets modified twice by
recordmcount, it will complain about it. To fix this issue, Russell wrote a
patch that checked if the file was hard linked more than once and would
unlink it if it was.

Linus Torvalds was not happy with the fact that recordmcount does this in
place modification. Instead of doing the unlink only if the file has two or
more hard links, it does the unlink all the time. In otherwords, it always
does a copy if it changed something. That is, it does the write out if a
change was made.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2016-10-26 23:15:39 +08:00
Russell King 38b8ae4f5e scripts: recordmcount: break hardlinks
commit dd39a26538e37f6c6131e829a4a510787e43c783 upstream.

recordmcount edits the file in-place, which can cause problems when
using ccache in hardlink mode.  Arrange for recordmcount to break a
hardlinked object.

Link: http://lkml.kernel.org/r/E1a7MVT-0000et-62@rmk-PC.arm.linux.org.uk

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2016-10-26 23:15:38 +08:00
libin 0c760ac877 recordmcount: Fix endianness handling bug for nop_mcount
commit c84da8b9ad3761eef43811181c7e896e9834b26b upstream.

In nop_mcount, shdr->sh_offset and welp->r_offset should handle
endianness properly, otherwise it will trigger Segmentation fault
if the recordmcount main and file.o have different endianness.

Link: http://lkml.kernel.org/r/563806C7.7070606@huawei.com

Signed-off-by: Li Bin <huawei.libin@huawei.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2016-10-26 23:15:23 +08:00
Richard Weinberger bd1bdbece9 localmodconfig: Use Kbuild files too
commit c0ddc8c745b7f89c50385fd7aa03c78dc543fa7a upstream.

In kbuild it is allowed to define objects in files named "Makefile"
and "Kbuild".
Currently localmodconfig reads objects only from "Makefile"s and misses
modules like nouveau.

Link: http://lkml.kernel.org/r/1437948415-16290-1-git-send-email-richard@nod.at

Reported-and-tested-by: Leonidas Spyropoulos <artafinde@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2016-03-21 09:17:51 +08:00
Michael Karcher 81bd39b083 scripts/recordmcount.pl: There is no -m32 gcc option on Super-H anymore
commit 1caf6aaaa47471831d77c75f094d4e00ad1ec808 upstream.

Compiling SH with gcc-4.8 fails due to the -m32 option not being
supported.

From http://buildd.debian-ports.org/status/fetch.php?pkg=linux&arch=sh4&ver=3.16.7-ckt4-1&stamp=1421425783

      CC      init/main.o
    gcc-4.8: error: unrecognized command line option '-m32'
    ld: cannot find init/.tmp_mc_main.o: No such file or directory
    objcopy: 'init/.tmp_mx_main.o': No such file
    rm: cannot remove 'init/.tmp_mx_main.o': No such file or directory
    rm: cannot remove 'init/.tmp_mc_main.o': No such file or directory

Link: http://lkml.kernel.org/r/1421537778-29001-1-git-send-email-kernel@mkarcher.dialup.fu-berlin.de
Link: http://lkml.kernel.org/r/54BCBDD4.10102@physik.fu-berlin.de

Cc: Matt Fleming <matt@console-pimps.org>
Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
2015-04-14 17:33:54 +08:00
vijay kumar c4a17c8dd4 scripts/dtc/libfdt: add integer overflow checks
This patch applies the same changes in the original commit
below to the dtc to keep both sources in sync.

original commit:
    lib: fdt: add integer overflow checks

    added integer overflow checks to avoid buffer over reads/write
    while using the fdt header fields.

    CRs-fixed: 705078.
    Change-Id: I062ee9e0610eeeeea32dd95695b18aa9dbca06ea

Bug: 19136881
Signed-off-by: Patrick Tjin <pattjin@google.com>
2015-01-28 15:48:51 +00:00
Zefan Li 699c06b386 sched: add macros to define bitops for task atomic flags
commit e0e5070b20 upstream.

This will simplify code when we add new flags.

v3:
- Kees pointed out that no_new_privs should never be cleared, so we
shouldn't define task_clear_no_new_privs(). we define 3 macros instead
of a single one.

v2:
- updated scripts/tags.sh, suggested by Peter

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Miao Xie <miaox@cn.fujitsu.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
[lizf: Backported to 3.4:
 - adjust context
 - remove no_new_priv code
 - add atomic_flags to struct task_struct]
2014-12-01 18:02:38 +08:00
Alex Smith 0e4c57c863 recordmcount/MIPS: Fix possible incorrect mcount_loc table entries in modules
commit 91ad11d7cc upstream.

On MIPS calls to _mcount in modules generate 2 instructions to load
the _mcount address (and therefore 2 relocations). The mcount_loc
table should only reference the first of these, so the second is
filtered out by checking the relocation offset and ignoring ones that
immediately follow the previous one seen.

However if a module has an _mcount call at offset 0, the second
relocation would not be filtered out due to old_r_offset == 0
being taken to mean that the current relocation is the first one
seen, and both would end up in the mcount_loc table.

This results in ftrace_make_nop() patching both (adjacent)
instructions to branches over the _mcount call sequence like so:

  0xffffffffc08a8000:  04 00 00 10     b       0xffffffffc08a8014
  0xffffffffc08a8004:  04 00 00 10     b       0xffffffffc08a8018
  0xffffffffc08a8008:  2d 08 e0 03     move    at,ra
  ...

The second branch is in the delay slot of the first, which is
defined to be unpredictable - on the platform on which this bug was
encountered, it triggers a reserved instruction exception.

Fix by initializing old_r_offset to ~0 and using that instead of 0
to determine whether the current relocation is the first seen.

Signed-off-by: Alex Smith <alex.smith@imgtec.com>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7098/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-07-06 18:49:19 -07:00
Andreas Schwab 7dff32efd2 powerpc: Add vr save/restore functions
commit 8fe9c93e74 upstream.

GCC 4.8 now generates out-of-line vr save/restore functions when
optimizing for size.  They are needed for the raid6 altivec support.

Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-05-18 05:25:56 -07:00
Ben Hutchings c502e92f7c deb-pkg: Fix cross-building linux-headers package
commit f8ce239dfc upstream.

builddeb generates a control file that says the linux-headers package
can only be built for the build system primary architecture.  This
breaks cross-building configurations.  We should use $debarch for this
instead.

Since $debarch is not yet set when generating the control file, set
Architecture: any and use control file variables to fill in the
description.

Fixes: cd8d60a20a ('kbuild: create linux-headers package in deb-pkg')
Reported-and-tested-by: "Niew, Sh." <shniew@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-03-30 21:40:30 -07:00
Jan Moskyto Matejka e7a95613d7 Modpost: fixed USB alias generation for ranges including 0x9 and 0xA
commit 03b56329f9 upstream.

Commit afe2dab4f6 ("USB: add hex/bcd detection to usb modalias generation")
changed the routine that generates alias ranges. Before that change, only
digits 0-9 were supported; the commit tried to fix the case when the range
includes higher values than 0x9.

Unfortunately, the commit didn't fix the case when the range includes both
0x9 and 0xA, meaning that the final range must look like [x-9A-y] where
x <= 0x9 and y >= 0xA -- instead the [x-9A-x] range was produced.

Modprobe doesn't complain as it sees no difference between no-match and
bad-pattern results of fnmatch().

Fixing this simple bug to fix the aliases.
Also changing the hardcoded beginning of the range to uppercase as all the
other letters are also uppercase in the device version numbers.

Fortunately, this affects only the dvb-usb-dib0700 module, AFAIK.

Signed-off-by: Jan Moskyto Matejka <mq@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-02-22 10:32:46 -08:00
Daniel Santos 93751c2630 kernel-doc: bugfix - multi-line macros
commit 6547842844 upstream.

Prior to this patch the following code breaks:

/**
 * multiline_example - this breaks kernel-doc
 */
 #define multiline_example( \
myparam)

Producing this error:

Error(somefile.h:983): cannot understand prototype: 'multiline_example( \ '

This patch fixes the issue by appending all lines ending in a blackslash
(optionally followed by whitespace), removing the backslash and any
whitespace after it prior to appending (just like the C pre-processor
would).

This fixes a break in kerel-doc introduced by the additions to rbtree.h.

Signed-off-by: Daniel Santos <daniel.santos@pobox.com>
Cc: Randy Dunlap <rdunlap@xenotime.net>
Cc: Michal Marek <mmarek@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2013-10-01 09:10:52 -07:00
Duy Truong 04e554807c Update copyright to The Linux Foundation
Change-Id: Ibead64ce2e901dede2ddd1b86088b88f2350ce92
Signed-off-by: Duy Truong <dtruong@codeaurora.org>
2013-03-15 17:07:39 -07:00
Bjørn Mork dca7fa1b9f USB: allow match on bInterfaceNumber
From 81df2d5943 upstream.

Some composite USB devices provide multiple interfaces
with different functions, all using "vendor-specific"
for class/subclass/protocol.  Another OS use interface
numbers to match the driver and interface. It seems
these devices are designed with that in mind - using
static interface numbers for the different functions.

This adds support for matching against the
bInterfaceNumber, allowing such devices to be supported
without having to resort to testing against interface
number whitelists and/or blacklists in the probe.

Change-Id: I0f991e507d041bbe12aa87403b9c2e1f0de274c2
Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
2013-03-15 17:07:24 -07:00
Matt Wagantall 67d11beed2 checkpatch: Excuse reverts from "summary line over 75 characters" check
Rather than forcing authors of reverts to truncate the summary line
because the "Revert" prefix added pushes it over the character limit,
excuse reverts from this rule.

Change-Id: I395dfff3327e360ef935d4a685c38df6577e3867
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
(cherry picked from commit 3c09aeb415d542b08257021992aadd965fcb3902)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit 952824addcec8487b8c800b0ef18ede547711381)
2013-03-07 15:20:03 -08:00
David Brown 137d1b2b4c checkpatch: strlen and strcmp should not be banned
Software security is an important issue, in general, but it is
especially important in Linux kernel code.  Buffer overflows can have
wide-reaching ramifications and can often be readily exploited to
compromise the entire system.  It is important for every developer to
be aware of security issues while writing code.

However, I've noticed a few "rules" about coding that are resulting in
code that isn't any more secure, and has the disadvantage of obscuring
what the code is doing.  In most instances, the "corrected" code is
actually wrong: we've traded a perceived lack of safety for incorrect
behavior.  These obfuscations also make this code more distant from
upstream kernel standards.

I'm only going to focus here on strcmp/strncmp and strlen/strnlen.  I
choose these two, because in the context of the kernel, it's not easy
to make a general rule, such as "always use the 'n' variant".  These
function have different behavior, and the 'n' isn't just a blanket fix
that makes them better.  In many instances, the correct call is the
plain variant (strcpy has a strlcpy variant which is usually helpful).

Let's start with strlen/strnlen.

	size_t strlen(const char *);
	size_t strnlen(const char *, size_t);

The strlen() function scans for a NUL byte within a string, and
returns the number of characters that had to be skipped to get there.

The strnlen() call is similar, but will stop after after a maximal
number of characters, and return that result.  This variant was
intended for storing variable length strings in fixed-sized buffers,
where the full-length case did not have a trailing NUL.  This storage
model is very uncommon, as is the use of strnlen().

The question becomes, what is the maximal length you should be giving
to strnlen().  If the string is truly variable length (allocated and
filled), there really isn't a meaningful value to use for this.  The
only time that a max length makes sense is when you have something
like:

	char name[MAX_NAME_LENGTH];

but, in this case, strnlen() is still probably not what you want to be
using.  It would be safe to use, if you check the result, and if it is
MAX_NAME_LENGTH, raise some kind of error case.  If later code assumes
there is a NUL at the end, there will still be a buffer overflow.  In
this case, it is much better to check the length before storing it in
this field, and make sure there is room for the NUL.

If the string is a constant, passing in a length doesn't make sense,
since you would have to know the length of the string to check that.
There is no safety issue with calling strlen() on a constant.

So, the simple rule for strnlen()/strlen() is:

  - If the string doesn't have an obvious bound length, such as an
    allocated string, use strlen().

  - If the string is a constant, use strlen().

  - If there is a fixed buffer, strnlen() might make sense, but it is
    probably better to change the design to avoid these types of
    strings.

The only case where strnlen really makes sense is when you have a
string that is passed in from the user.  In this case, it is very
important to check the result, and if the length is at the maximum,
return an error, and don't try to do any processing on the string.

Moving on to strcmp/strncmp.  These functions are similar, except that
they take two string arguments, which gives a lot more combinations.

	int strcmp(const char *, const char *);
	int strncmp(const char *, const char *, size_t);

These will walk both strings (at the same time), and stop when
reaching the first difference between them.  This means that they will
never go further than the length of the shortest string being
compared.  As in strnlen, the max argument to strncmp sets a limit on
the comparison.  Similar to strnlen, the results are unusual when the
limit is reached, but in a sense, even worse, since it may consider
the strings equal without ever reaching the end of either.

Looking over the 200 some uses of strncmp in the msm code, almost all
of them do something akin to:

	strncmp(value, constant, strlen(constant))

If the call has added 1 to the 'strlen' result, the strncmp would just
become an inefficient, but otherwise identical version of strcmp.
However, without the +1, this compares the prefix of 'value' instead
of the entire string.  Only one instance of strncmp in the code
appears to be intentionally checking for a prefix.  The rest have
changed a simple string compare into an unintentional prefix match.

Because there are two strings, it is a little more complex to
determine which to use, but it is very similar.  It might seem that
strncmp() would be useful for checking an unknown buffer (say from
userspace).  However, since strncmp()'s result doesn't distinguish
between finding the end of the string, or hitting the max, there's no
way to know.  Some guidelines:

  - If one of the strings has a known bound length (such as a
    constant, or another string whose length has already been
    checked), AND this bound length is within the expected buffer of
    the other string, it is safe to use strcmp().

  - Otherwise, you may need to use something like strnlen() to
    determine a maximum length before calling strcmp().

  - strncmp() is useful to test a string for a prefix.  No other uses
    make sense.

To facilitate fixing these, remove strlen(), strcmp(), and
strcasecmp() from the list of calls that are banned.  Problems with
these calls need to be caught at a higher level (such as review), and
replacing them with the 'n' variants doesn't help anything.

This will be followed by some patches that fixup the incorrect code
introduced by this "ban".

Change-Id: I77dfe1f2f58e8c951e4b38b23f4ec79f8209b1dc
Signed-off-by: David Brown <davidb@codeaurora.org>
2013-02-27 18:19:30 -08:00
Steve Muckle b657cc0ec7 checkpatch: add new message type string
Many messsages are missing the new message type parameter, which
causes warning messages and a lack of the line number from the
offending line in the patch.

Change-Id: I69f2283c3dc27edd66fd2676c8be45664699dba6
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
2013-02-27 18:10:43 -08:00
Rohit Vaswani b45143752d scripts/checkpatch.pl: fixup
Change-Id: I76a7f5fd446a9f40d8294f03d2c355273af59905
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
2013-02-20 02:50:06 -08:00
Olav Haugan fa79a44270 checkpatch: Check for unsafe string functions
There are many string based functions that are unsafe
to use. Some of the functions are unsafe to use because
of the possibility of overflow while others cannot
guarantee that the resultant string is NULL-terminated.

Add check for these functions and log message indicating
which safe functions can be used instead.

Change-Id: Id305d98df241e3fd257529529739dcd4f3659186
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 665be0da353f69f85cb1acea19279adf6ccb5b52)
2013-02-20 02:50:05 -08:00
Steve Muckle 097d733966 checkpatch: recognize only specific tags when ending commit text
There are some very frequently used tags that checkpatch can look
for as an ending to the commit text rather than using a pattern,
which can generate false positives in the "no commit text" rule.

Change-Id: I5b4400017b8273bcd9f5a59b3e28965c0062bef4
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 336a3ae6253031d6a0de11882ac24a11f83d3323)
2013-02-20 02:50:05 -08:00
Steve Muckle 87c8e7d5be checkpatch: require commit text
Commit text is almost always necessary to explain why a change is
needed. Exceptions are rare enough that these can be granted through
manual checkpatch overrides.

Change-Id: I926b2276f717940c2fec77a6709fa3088b1bf0c3
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit d3b3b64c907dbf2244250fc4b389562f2efedee2)
2013-02-20 02:50:04 -08:00
Pankaj Kumar 3f3f761f9c checkpatch: Add check for vreg_xxx api in opensource drivers
Vreg API implementation is deprecated. We are using
Linux regulator framework now. Hence vreg API should
not be used.

Change-Id: I8e31dac66592d2d195d190b770a436e93206cf8b
Signed-off-by: Pankaj Kumar <pakuma@codeaurora.org>
(cherry picked from commit adfb933a24911e3514a2f1b6fe1b1a9151fec56d)
2013-02-20 02:50:04 -08:00
Rohit Vaswani 26ec0b6b5d checkpatch: Add check for gpiomux usage in msm board files
MSM has a board-*-gpiomux file where all the gpiomux configs reside.
Warn if a non gpiomux board file tries to add gpiomux configs.
The camera board file is an exception to this rule.

Change-Id: Ibab190dcbd7ea78e7ca150142c68c5ae881e4e06
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
(cherry picked from commit 60d78bb9809e7d4d1c3dc1425cbfd9e649e87c1c)
2013-02-20 02:50:03 -08:00
Gregory Bean d8ac9d4585 checkpatch: repair faulty executable-bit check.
Existing executable-bit test only works on second and later files
contained in the patch.  Correct this so all patches in the file
are tested.

Change-Id: Ie9363473f0d2fc067f9c593c86495d15e8e5d546
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit 246e1f183dd3c2bfe63722ca5b207473cb9a0219)

Conflicts:

	scripts/checkpatch.pl
2013-02-20 02:50:02 -08:00
Gregory Bean ec9255dbf8 checkpatch: complain about the use of dsb().
Now that mb() does what we want, dsb() should be discouraged.

Change-Id: Ib8fe8f44f669753c3d91fac3c6e598e117d6d90e
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit 9c0619be7b93ad114d6f33a749d905ddff93df7d)
2013-02-20 02:50:02 -08:00
Gregory Bean 136c5a1cd0 checkpatch: close filp_open loophole.
filp_open allows people to get around the ban on sys_open.
Close the loophole.

Change-Id: I6e2be62e848cbc064e07008d0886c0d003c8be4b
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit bb181a18a813a70176f71a0c64aa572fcfbef0f0)
2013-02-20 02:50:01 -08:00
Gregory Bean 4409ccd825 checkpatch: Handle long multi-line macros better.
Improve parsing of multiline macros which run beyond the available
diff context.  These beyond-the-horizon macros previously caused
two distinct naughty behaviors:
  - The scanner, confused by the trailing backslash, would grab
    the header of the next context hunk and treat it as the last
    line of the preceding macro.
  - The analyzer, unable to fully reduce the macro, would blame
    the patch for submitting an unbalanced or unprotected macro.

Change-Id: I6b7dd3d577c524d30b59dff7b20393bb5135f16d
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit ddd028c47b4d91aa9c0e97445eb584b2de367769)
2013-02-20 02:50:01 -08:00
Gregory Bean 3a4c8c77cc checkpatch: deprecate unbounded string functions.
Unbounded string functions are overflow risks.  The 'n'
versions of those functions should be used instead.

Change-Id: Ice0fb3ebdae9aa88cc7e764ffdf68cbed857febf
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit 15e1e97d66dd6a6039c1ec2bd549a632fe361128)
2013-02-20 02:50:00 -08:00
Gregory Bean 55bb2c050a checkpatch: forbid implied-barrier I/O functions.
Forbid read[bwl], write[bwl], in[bwl], and out[bwl], as they
contain a 'stealth barrier' which can harm performance.
Developers are expected to call appropriate __raw_* or *_relaxed
APIs and manage barriers explicitly.

Change-Id: Ie4da221c91a0505917199db9e2fdb704c3e47d44
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit 032fd4ba09e195d9913c08f460130da9905936ef)
2013-02-20 02:49:59 -08:00
Gregory Bean 20a44b003b checkpatch: Merge continuation-header handling from .38.
This commit is a cherry pick and squash of commits:
85c2ee62d37c19456c6dc83db262123956f010ac
4bc7c6001daba7d4037f54f67bae7fa90f759402

  checkpatch: Handle continuation headers.

  Continuation headers baffle checkpatch, as it can only operate
  on one line of context at a time.  When continuation headers are found,
  put them up with the header they're continuing so the whole thing
  can be parsed in a single line of context.

  checkpatch: Don't treat diffs as patches.

  The patch-header cleanup code assumed that it would only ever
  see patches, which was of course hogwash.  This lead to crazy
  results as it tried to wrap what it thought were continuation
  lines at the beginnings of raw diffs.

Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit 57d50ae730a057ee1099a94a397475bfd147d97b)

Conflicts:

	scripts/checkpatch.pl

Change-Id: I60b2d914ada9a8690b89ffb8c1e32a8b81a5e715
2013-02-20 02:49:59 -08:00
Gregory Bean 5bc97df95b checkpatch: forbid filesystem accesses from within the kernel.
Use of the sys_open/close/read/write system calls from within
kernel code is inappropriate, and now triggers errors.

Change-Id: I98e20513c257d0664684b7144585853f617d771a
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit ee62f2afcac1bcb180b2f0dddf2c8f5cda54bc5b)
2013-02-20 02:49:58 -08:00
David Brown d0d4b63246 Revert "checkpatch: reject unrelaxed readl/writel."
This reverts commit 66b2a3733e7219e5291c633eb5778bec6500b74d.

Possibly can happen after necessary code changes are in place.

Change-Id: I04e092158dda2b5f5ca029378d1e7dc863de6001
Signed-off-by: David Brown <davidb@codeaurora.org>
(cherry picked from commit 4235f0aeb789321b36eb01f29ffb329fc9d2169c)
2013-02-20 02:49:57 -08:00
Gregory Bean 31fbea03d9 checkpatch: reject unrelaxed readl/writel.
Change-Id: I9490245ba24df51f1b4a69e2bb46b27da13a333a
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit 66b2a3733e7219e5291c633eb5778bec6500b74d)
2013-02-20 02:49:57 -08:00
Gregory Bean b4bea2d7a9 Don't complain about MIME headers.
When patches contain extended character sets, patches will contain
MIME headers after the subject line, which should not be confused
for a too-long summary line.

Signed-off-by: Gregory Bean <gbean@codeaurora.org>
Change-Id: If17d17cc7513eb644d75f486b9cdea3a09ba0dbe
(cherry picked from commit 8e6b9d3790595198a34320f1c3f4504cd258fed1)
2013-02-20 02:49:56 -08:00
Bryan Huntsman fa3e178ef5 Revert "checkpatch: add check for too short Kconfig descriptions"
This reverts commit 3354957a4f.

Signed-off-by: Bryan Huntsman <bryanh@codeaurora.org>
(cherry picked from commit 6839bfe7291e24589884af37de8622ff2bea31e6)
2013-02-20 02:49:56 -08:00
Matt Wagantall cc32440107 checkpatch: Import additional rules from android-msm-2.6.32 to msm-2.6.35
Several checkpatch enhancements are imported from android-msm-2.6.32.
These include:

commit 83ec26e869ac7e967fd5382f9e1979536897d42a
Author: Matt Wagantall <mattw@codeaurora.org>
Date:   Thu Jun 3 12:28:18 2010 -0700

    checkpatch: Exceptions for CLK_* macros and some spaces in macros

    Add CLK_* macros used in MSM clock drivers to the list of exceptions
    for the "Macros with complex values should be enclosed in parenthesis"
    test.

    Also, allow spaces following open branckets for macros where the
    macro is the first token on the line, the space preceds a decimal
    number, and the line ends with ")," or ")". Such arrangements can
    be useful for aligning numerical columns of tables when the rows
    are described by macros.

    Change-Id: I7701119ada2ea8fd646e5448eae51786bbf1e8fa
    Signed-off-by: Matt Wagantall <mattw@codeaurora.org>

commit d3ccf20187826d2cfbf41eda3f9e1a38e35b79bf
Author: Rick Adams <rgadams@codeaurora.org>
Date:   Mon Jan 4 13:06:09 2010 -0800

    checkpatch: warn on subject line not followed by blank line

    Fixed case when no warning generated for long subject line that is
    wrapped to more than one line, and all lines are less than line limit.

    New warning message added:
    "non-blank line after summary line"
    Now there are two warnings possible for the subject line, the original
    line over limit and the new one. Depending on the error(s) any
    combination of the two warnings are possible.

    Commit text requirements now:
    1) Must be less than 75 characters
    2) Must be followed by blank line.

    Change-Id: If7ee833339c5be947bb1dd2a52d5d1d9ddfe5de6
    Signed-off-by: Rick Adams <rgadams@codeaurora.org>

commit ae617dec94111b127c33ae9c979e51b5bd8b5292
Author: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Date:   Thu Oct 1 12:01:44 2009 -0700

    checkpatch: check for #if 0/#if 1

    Warn if #if 1 or #if 0 is present.

    Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>

commit 168e8da627f99e421be9375ed572df6b1039854f
Author: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Date:   Thu Oct 1 12:01:44 2009 -0700

    checkpatch: check for execute permissions on non code files

    Make checkpatch.pl check execute permissions on non code files

    Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>

commit be24800e1cdd44d8b0e00f212c022f34e1402eb4
Author: Steve Muckle <smuckle@codeaurora.org>
Date:   Fri Apr 3 16:19:20 2009 -0700

    checkpatch: check new files for executable permissions

    Look for executable permissions on new files as well as in mode
    changes on existing files.

    Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

commit b45a236b62928e0b11fbeff1471d9b1efc508884
Author: Steve Muckle <smuckle@codeaurora.org>
Date:   Fri Mar 13 15:46:36 2009 -0700

    checkpatch: warn on long summary, commit text lines

    Warn on summary or commit text lines greater than 75 characters.
    The summary and commit text are indented and may wrap on a terminal
    if they are longer than 75 characters.

    Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

Change-Id: Iae92cdc8ffecc5315761bc91e883d8ea2f4877cc
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
(cherry picked from commit d17f580ee07441770498b54159e3322f8186fc3e)

Conflicts:

	scripts/checkpatch.pl
2013-02-20 02:49:55 -08:00
Patrick Pannuto d917e71c27 Checkpatch: Backport changes from 2.6.35
Backport a series of checkpatch changes from 2.6.35; having
these checks in our tree now will help with upstreaming
efforts.

A summary of the changes:

(trivial) remove Dave Jones' email
Add initconst attribute
Switch printk exception to logFunctions
check for spaces before a quoted newline
check for space before tabs
improved check spacing on parentheses
improved conditional checking
add some exceptions to multi-statement macro exceptions
Check that the storage class is at the beginning of a declaration
check for sizeof(&)
check for various ops structs, ensure they are const.
check for lockdep_set_novalidate_class

The following commits are included:

commit dbf004d788
Author: Dave Jones <davej@redhat.com>
Date:   Tue Jan 12 16:59:52 2010 -0500

    remove my email address from checkpatch.

    Maybe this will stop people emailing me about it.

    Signed-off-by: Dave Jones <davej@redhat.com>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 52131292c0
Author: Wolfram Sang <w.sang@pengutronix.de>
Date:   Fri Mar 5 13:43:51 2010 -0800

    checkpatch: fix false positive on __initconst

    checkpatch falsely complained about '__initconst' because it thought the
    'const' needed a space before.  Fix this by changing the list of
    attributes:

    - add '__initconst'
    - force plain 'init' to contain a word-boundary at the end

    Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 691e669ba8
Author: Joe Perches <joe@perches.com>
Date:   Fri Mar 5 13:43:51 2010 -0800

    checkpatch.pl: allow > 80 char lines for logging functions not just printk

    Signed-off-by: Joe Perches <joe@perches.com>
    Cc: Andy Whitcroft <apw@canonical.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 3354957a4f
Author: Andi Kleen <ak@linux.intel.com>
Date:   Mon May 24 14:33:29 2010 -0700

    checkpatch: add check for too short Kconfig descriptions

    I've seen various new Kconfigs with rather unhelpful one liner
    descriptions.  Add a Kconfig warning for a minimum length of the Kconfig
    help section.

    Right now I arbitarily chose 4. The exact value can be debated.

    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Andi Kleen <ak@linux.intel.com>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 5e79d96eed
Author: Joe Perches <joe@perches.com>
Date:   Fri Mar 5 13:43:55 2010 -0800

    checkpatch: warn on unnecessary spaces before quoted newlines

    Signed-off-by: Joe Perches <joe@perches.com>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 08e4436566
Author: Alberto Panizzo <maramaopercheseimorto@gmail.com>
Date:   Fri Mar 5 13:43:54 2010 -0800

    checkpatch.pl: warn if an adding line introduce spaces before tabs.

    Signed-off-by: Alberto Panizzo <maramaopercheseimorto@gmail.com>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 42bdf74c95
Author: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
Date:   Fri Mar 5 13:43:50 2010 -0800

    checkpatch: trivial fix for trailing statements check

    In case if the statement and the conditional are in one line, the line
    appears in the report doubly.

    And items of this check have no blank line before the next item.

    This patch fixes these trivial problems, to improve readability of the
    report.

    [sample.c]
      > if (cond1
      >        && cond2
      >        && cond3) func_foo();
      >
      > if (cond4) func_bar();

    Before:
      > ERROR: trailing statements should be on next line
      > #1: FILE: sample.c:1:
      > +if (cond1
      > [...]
      > +       && cond3) func_foo();
      > ERROR: trailing statements should be on next line
      > #5: FILE: sample.c:5:
      > +if (cond4) func_bar();
      > +if (cond4) func_bar();
      > total: 2 errors, 0 warnings, 5 lines checked

    After:
      > ERROR: trailing statements should be on next line
      > #1: FILE: sample.c:1:
      > +if (cond1
      > [...]
      > +       && cond3) func_foo();
      >
      > ERROR: trailing statements should be on next line
      > #5: FILE: sample.c:5:
      > +if (cond4) func_bar();
      >
      > total: 2 errors, 0 warnings, 5 lines checked

    Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
    Cc: Andy Whitcroft <apw@canonical.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 22fd2d3e4f
Author: Stefani Seibold <stefani@seibold.net>
Date:   Fri Mar 5 13:43:52 2010 -0800

    checkpatch.pl: add union and struct to the exceptions list

    Here is a small code snippet, which will be complained about by
    checkpatch.pl:

    #define __STRUCT_KFIFO_COMMON(recsize, ptrtype) \
        union { \
                struct { \
                        unsigned int    in; \
                        unsigned int    out; \
                }; \
                char            rectype[recsize]; \
                ptrtype         *ptr; \
                const ptrtype   *ptr_const; \
        };

    This construct is legal and safe, so checkpatch.pl should accept this.  It
    should be also true for struct defined in a macro.

    Add the `struct' and `union' keywords to the exceptions list of the
    checkpatch.pl script, to prevent error message "Macros with multiple
    statements should be enclosed in a do - while loop".  Otherwise it is not
    possible to build a struct or union with a macro.

    Signed-off-by: Stefani Seibold <stefani@seibold.net>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit d4977c78e9
Author: Tobias Klauser <tklauser@distanz.ch>
Date:   Mon May 24 14:33:30 2010 -0700

    checkpatch: warn on declaration with storage class not at the beginning

    The C99 specification states in section 6.11.5:

    The placement of a storage-class specifier other than at the beginning
    of the declaration specifiers in a declaration is an obsolescent
    feature.

    Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
    Acked-by: Jean Delvare <khali@linux-fr.org>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 8f53a9b80f
Author: Joe Perches <joe@perches.com>
Date:   Fri Mar 5 13:43:48 2010 -0800

    scripts/checkpatch.pl: add WARN on sizeof(&foo)

    sizeof(&foo) is frequently an error.  Warn on its use.

    Signed-off-by: Joe Perches <joe@perches.com>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 79404849e9
Author: Emese Revfy <re.emese@gmail.com>
Date:   Fri Mar 5 13:43:53 2010 -0800

    checkpatch.pl: extend list of expected-to-be-const structures

    Based on Arjan's suggestion, extend the list of ops structures that should
    be const.

    Signed-off-by: Emese Revfy <re.emese@gmail.com>
    Cc: Andy Whitcroft <apw@shadowen.org>
    Cc: Arjan van de Ven <arjan@infradead.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

commit 1704f47b50
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Fri Mar 19 01:37:42 2010 +0100

    lockdep: Add novalidate class for dev->mutex conversion

    The conversion of device->sem to device->mutex resulted in lockdep
    warnings. Create a novalidate class for now until the driver folks
    come up with separate classes. That way we have at least the basic
    mutex debugging coverage.

    Add a checkpatch error so the usage is reserved for device->mutex.

    [ tglx: checkpatch and compile fix for LOCKDEP=n ]

    Signed-off-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Change-Id: I11495554d7d393659e5e0d7188cdc1744e25b6ba
Signed-off-by: Patrick Pannuto <ppannuto@codeaurora.org>
(cherry picked from commit 4657bf482381583b08b34ed5ea6f7d3ad162807c)

Conflicts:

	scripts/checkpatch.pl
2013-02-20 02:49:54 -08:00
Patrick Pannuto e388f38442 Checkpatch: Print location when catching return code error
Display context so users can see where there error was

OLD:
	ERROR: illegal return value, please use an error code

NEW:
	ERROR: illegal return value, please use an error code
	#152: test.c:5:
	+	return -1;

Change-Id: I098004d9a5dbeb6c39b35b84ac94fd7a861849d7
Signed-off-by: Patrick Pannuto <ppannuto@codeaurora.org>
(cherry picked from commit 8d09803de5d629f3ebc9cb357a40b5937a5d171e)
2013-02-20 02:49:54 -08:00
Gregory Bean 45da08a85b Revert "checkpatch: Add warning for blank lines in header"
This reverts commit 8212698c653945d0fd0783829822917bf13a5aab.
The original commit incorrectly prevents the following:
  - Commit messages which cite other commit messages, which
    are commonly used for attribution;
  - Any use of checkpatch which doesn't contain a full mail header,
    such as 'show <ref> | checkpatch.pl -'

Change-Id: I681a97913432d05bf66290cf74972aaa4e03fe5d
Signed-off-by: Gregory Bean <gbean@codeaurora.org>
(cherry picked from commit c73e32b4a1a59e3a33e9c8975ab08b5475d30f3e)
2013-02-20 02:49:53 -08:00
Patrick Pannuto dc4e47c544 checkpatch: Check for illegal return codes
The only legal integer return is 0, anything else
following "return" should be -ERRCODE or a function.

http://lkml.org/lkml/2010/7/23/318
  There's lots of "return -1;" statements in this patch - it's obscene
  that this is used to indicate "some error occurred" in kernel space
  rather than a real errno value - even when an existing function
  (eg, request_irq) gave you an error code already.

  Please note this for the future - and please review patches on this
  point internally first.

Change-Id: I16268b2ee034f0b3b899115e45c28acfa734ddec
Signed-off-by: Patrick Pannuto <ppannuto@codeaurora.org>
(cherry picked from commit 39531a47164294315b5a7256b520fe22d6e87013)
2013-02-20 02:49:53 -08:00
Israel Schlesinger 4be1c09bc3 checkpatch: remove column limit for checkpatch patches
Currently checkpatch is enforcing an 80 character column
limit. This should not be applied for patches modifying
checkpatch.

Change-Id: I8e8935e633d79a7ee535ce6a90e54447a22d9a91
Signed-off-by: Israel Schlesinger <israels@codeaurora.org>
(cherry picked from commit 4aa1b864119e2d0e49efefcd6dba7349f13c3939)

Conflicts:

	scripts/checkpatch.pl
2013-02-20 02:49:52 -08:00