An error occurred while fetching folder content.
dma-debug: Fix the overlap() function to be correct and readable
Ingo Molnar authored
Linus noticed how unclean and buggy the overlap() function is:

 - It uses convoluted (and bug-causing) positive checks for
   range overlap - instead of using a more natural negative
   check.

 - Even the positive checks are buggy: a positive intersection
   check has four natural cases while we checked only for three,
   missing the (addr < start && addr2 == end) case for example.

 - The variables are mis-named, making it non-obvious how the
   check was done.

 - It needlessly uses u64 instead of unsigned long. Since these
   are kernel memory pointers and we explicitly exclude highmem
   ranges anyway we cannot ever overflow 32 bits, even if we
   could. (and on 64-bit it doesnt matter anyway)

All in one, this function needs a total revamp. I used Linus's
suggestions minus the paranoid checks (we cannot overflow really
because if we get totally bad DMA ranges passed far more things
break in the systems than just DMA debugging). I also fixed a
few other small details i noticed.
Reported-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Cc: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
f39d1b97
Name Last commit Last update
..
lzo lzo: use get/put_unaligned_* helpers
reed_solomon lib: Remove unnecessary inclusions of asm/semaphore.h
zlib_deflate lib/: Spelling fixes
zlib_inflate bzip2/lzma: library support for gzip, bzip2 and lzma decompression
.gitignore Add some basic .gitignore files
Kconfig lib: Provide generic atomic64_t implementation
Kconfig.debug kmemleak: Do not force the slab debugging Kconfig options
Kconfig.kgdb kgdb: remove the requirement for CONFIG_FRAME_POINTER
Kconfig.kmemcheck kmemcheck: make kconfig accessible for other architectures
Makefile lib: add lib/gcd.c
argv_split.c LIB: Replace inappropriate include of <linux/bug.h>
atomic64.c lib: Provide generic atomic64_t implementation
audit.c [PATCH] audit signal recipients
bcd.c rtc: BCD codeshrink
bitmap.c bitmap: fix end condition in bitmap_find_free_region
bitrev.c lib: export bitrev16
bug.c allow bug table entries to use relative pointers (and use it on x86-64)
bust_spinlocks.c oops handling: ensure that any oops is flushed to the mtdoops console
check_signature.c uninline check_signature()
checksum.c lib/checksum.c: fix endianess bug
cmdline.c generic, memparse(): constify argument
cpumask.c x86: remove some alloc_bootmem_cpumask_var calling
crc-ccitt.c [PATCH] kernel-doc for lib/crc*.c
crc-itu-t.c CRC ITU-T V.41
crc-t10dif.c [SCSI] lib: Add support for the T10 (SCSI) Data Integrity Field CRC
crc16.c
crc32.c
crc32defs.h
crc7.c
ctype.c
debug_locks.c
debugobjects.c
dec_and_lock.c
decompress.c
decompress_bunzip2.c
decompress_inflate.c
decompress_unlzma.c
devres.c
div64.c
dma-debug.c
dump_stack.c
dynamic_debug.c
extable.c
fault-inject.c
find_last_bit.c
find_next_bit.c
gcd.c
gen_crc32table.c
genalloc.c
halfmd4.c
hexdump.c
hweight.c
idr.c
inflate.c
int_sqrt.c
iomap.c
iomap_copy.c
iommu-helper.c
ioremap.c
irq_regs.c
is_single_threaded.c
kasprintf.c
kernel_lock.c
klist.c
kobject.c
kobject_uevent.c
kref.c
libcrc32c.c
list_debug.c
lmb.c
locking-selftest-hardirq.h
locking-selftest-mutex.h
locking-selftest-rlock-hardirq.h
locking-selftest-rlock-softirq.h
locking-selftest-rlock.h
locking-selftest-rsem.h
locking-selftest-softirq.h
locking-selftest-spin-hardirq.h
locking-selftest-spin-softirq.h
locking-selftest-spin.h
locking-selftest-wlock-hardirq.h
locking-selftest-wlock-softirq.h
locking-selftest-wlock.h
locking-selftest-wsem.h
locking-selftest.c
nlattr.c
parser.c
percpu_counter.c
plist.c
prio_heap.c
prio_tree.c
proportions.c
radix-tree.c
random32.c
ratelimit.c
rational.c
rbtree.c
reciprocal_div.c
rwsem-spinlock.c
rwsem.c