An error occurred while fetching folder content.
ida: don't use BUG_ON() for debugging
Linus Torvalds authored
commit fc82bbf4 upstream.

This is another old BUG_ON() that just shouldn't exist (see also commit
a382f8fe: "signal handling: don't use BUG_ON() for debugging").

In fact, as Matthew Wilcox points out, this condition shouldn't really
even result in a warning, since a negative id allocation result is just
a normal allocation failure:

  "I wonder if we should even warn here -- sure, the caller is trying to
   free something that wasn't allocated, but we don't warn for
   kfree(NULL)"

and goes on to point out how that current error check is only causing
people to unnecessarily do their own index range checking before freeing
it.

This was noted by Itay Iellin, because the bluetooth HCI socket cookie
code does *not* do that range checking, and ends up just freeing the
error case too, triggering the BUG_ON().

The HCI code requires CAP_NET_RAW, and seems to just result in an ugly
splat, but there really is no reason to BUG_ON() here, and we have
generally striven for allocation models where it's always ok to just do

    free(alloc());

even if the allocation were to fail for some random reason (usually
obviously that "random" reason being some resource limit).

Fixes: 88eca020

 ("ida: simplified functions for id allocation")
Reported-by: default avatarItay Iellin <ieitayie@gmail.com>
Suggested-by: default avatarMatthew Wilcox <willy@infradead.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
f2eef5a2
Name Last commit Last update
..
842 lib: 842: no need to check return value of debugfs_create functions
crypto crypto: memneq - move into lib/
dim dim: initialize all struct fields
fonts lib: fix spelling mistakes
kunit kunit: fix debugfs code to use enum kunit_status, not bool
livepatch Merge tag 'kbuild-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
lz4 lz4: fix LZ4_decompress_safe_partial read out of bound
lzo lib/lzo/lzo1x_compress.c: make lzogeneric1x_1_compress() static
math math: make RATIONAL tristate
mpi lib/mpi: export mpi_rshift
pldmfw lib: fix spelling mistakes
raid6 lib/raid6: Include <asm/ppc-opcode.h> for VPERMXOR
reed_solomon lib: fix spelling mistakes
test_fortify fortify: Detect struct member overflows in memset() at compile-time
vdso lib/vdso: Add vdso_data pointer as input to __arch_get_timens_vdso_data()
xz lib/xz, lib/decompress_unxz.c: Fix spelling in comments
zlib_deflate lib/zlib: add zlib_deflate_dfltcc_enabled() function
zlib_dfltcc zlib: move EXPORT_SYMBOL() and MODULE_LICENSE() out of dfltcc_syms.c
zlib_inflate lib/zlib_inflate/inffast: check config in C to avoid unused function warning
zstd lib: zstd: Don't add -O3 to cflags
.gitignore fortify: Add compile-time FORTIFY_SOURCE tests
Kconfig crypto: memneq - move into lib/
Kconfig.debug random: remove ratelimiting for in-kernel unseeded randomness
Kconfig.kasan kasan: allow enabling KASAN_VMALLOC and SW/HW_TAGS
Kconfig.kcsan Revert "ubsan, kcsan: Don't combine sanitizer with kcov on clang"
Kconfig.kfence
Kconfig.kgdb
Kconfig.ubsan
Makefile
argv_split.c
ashldi3.c
ashrdi3.c
asn1_decoder.c
asn1_encoder.c
assoc_array.c
atomic64.c
atomic64_test.c
audit.c
bcd.c
bch.c
bitfield_kunit.c
bitmap.c
bitrev.c
bootconfig.c
bsearch.c
btree.c
bucket_locks.c
bug.c
build_OID_registry
buildid.c
bust_spinlocks.c
check_signature.c
checksum.c
clz_ctz.c
clz_tab.c
cmdline.c
cmdline_kunit.c
cmpdi2.c
compat_audit.c
cpu_rmap.c
cpumask.c
crc-ccitt.c
crc-itu-t.c
crc-t10dif.c
crc16.c
crc32.c
crc32defs.h
crc32test.c
crc4.c
crc64-rocksoft.c
crc64.c
crc7.c
crc8.c
ctype.c
debug_info.c
debug_locks.c
debugobjects.c
dec_and_lock.c
decompress.c
decompress_bunzip2.c
decompress_inflate.c
decompress_unlz4.c
decompress_unlzma.c
decompress_unlzo.c
decompress_unxz.c
decompress_unzstd.c
devmem_is_allowed.c
devres.c
digsig.c
dump_stack.c
dynamic_debug.c
dynamic_queue_limits.c
earlycpio.c
errname.c
error-inject.c
errseq.c
extable.c
fault-inject-usercopy.c
fault-inject.c
fdt.c