linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Itay Iellin <ieitayie@gmail.com>,
	Matthew Wilcox <willy@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5.18 105/112] ida: dont use BUG_ON() for debugging
Date: Mon, 11 Jul 2022 11:07:45 +0200	[thread overview]
Message-ID: <20220711090552.550441998@linuxfoundation.org> (raw)
In-Reply-To: <20220711090549.543317027@linuxfoundation.org>

From: Linus Torvalds <torvalds@linux-foundation.org>

commit fc82bbf4dede758007763867d0282353c06d1121 upstream.

This is another old BUG_ON() that just shouldn't exist (see also commit
a382f8fee42c: "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: 88eca0207cf1 ("ida: simplified functions for id allocation")
Reported-by: Itay Iellin <ieitayie@gmail.com>
Suggested-by: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 lib/idr.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/lib/idr.c
+++ b/lib/idr.c
@@ -491,7 +491,8 @@ void ida_free(struct ida *ida, unsigned
 	struct ida_bitmap *bitmap;
 	unsigned long flags;
 
-	BUG_ON((int)id < 0);
+	if ((int)id < 0)
+		return;
 
 	xas_lock_irqsave(&xas, flags);
 	bitmap = xas_load(&xas);



  parent reply	other threads:[~2022-07-11  9:36 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11  9:06 [PATCH 5.18 000/112] 5.18.11-rc1 review Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 001/112] io_uring: fix provided buffer import Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 002/112] ALSA: usb-audio: Workarounds for Behringer UMC 204/404 HD Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 003/112] ALSA: hda/realtek: Add quirk for Clevo L140PU Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 004/112] ALSA: cs46xx: Fix missing snd_card_free() call at probe error Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 005/112] can: bcm: use call_rcu() instead of costly synchronize_rcu() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 006/112] can: grcan: grcan_probe(): remove extra of_node_get() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 007/112] can: gs_usb: gs_usb_open/close(): fix memory leak Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 008/112] can: m_can: m_can_chip_config(): actually enable internal timestamping Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 009/112] can: m_can: m_can_{read_fifo,echo_tx_event}(): shift timestamp to full 32 bits Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 010/112] can: kvaser_usb: replace run-time checks with struct kvaser_usb_driver_info Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 011/112] can: kvaser_usb: kvaser_usb_leaf: fix CAN clock frequency regression Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 012/112] can: kvaser_usb: kvaser_usb_leaf: fix bittiming limits Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 013/112] can: mcp251xfd: mcp251xfd_regmap_crc_read(): improve workaround handling for mcp2517fd Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 014/112] can: mcp251xfd: mcp251xfd_regmap_crc_read(): update workaround broken CRC on TBC register Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 015/112] can: mcp251xfd: mcp251xfd_stop(): add missing hrtimer_cancel() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 016/112] bpf: Fix incorrect verifier simulation around jmp32s jeq/jne Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 017/112] bpf: Fix insufficient bounds propagation from adjust_scalar_min_max_vals Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 018/112] usbnet: fix memory leak in error case Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 019/112] net: rose: fix UAF bug caused by rose_t0timer_expiry Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 020/112] net: lan966x: hardcode the number of external ports Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 021/112] netfilter: nft_set_pipapo: release elements in clone from abort path Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 022/112] netfilter: nf_tables: stricter validation of element data Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 023/112] selftests/net: fix section name when using xdp_dummy.o Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 024/112] can: mcp251xfd: mcp251xfd_register_get_dev_id(): use correct length to read dev_id Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 025/112] can: mcp251xfd: mcp251xfd_register_get_dev_id(): fix endianness conversion Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 026/112] can: rcar_canfd: Fix data transmission failed on R-Car V3U Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 027/112] ASoC: qdsp6: q6apm-dai: unprepare stream if its already prepared Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 028/112] MAINTAINERS: Remove iommu@lists.linux-foundation.org Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 029/112] iommu/vt-d: Fix PCI bus rescan device hot add Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 030/112] iommu/vt-d: Fix RID2PASID setup/teardown failure Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 031/112] cxl/mbox: Use __le32 in get,set_lsa mailbox structures Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 032/112] cxl: Fix cleanup of port devices on failure to probe driver Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 033/112] fbdev: fbmem: Fix logo center image dx issue Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 034/112] fbmem: Check virtual screen sizes in fb_set_var() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 035/112] fbcon: Disallow setting font bigger than screen size Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 036/112] fbcon: Prevent that screen size is smaller than font size Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 037/112] PM: runtime: Redefine pm_runtime_release_supplier() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 038/112] PM: runtime: Fix supplier device management during consumer probe Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 039/112] memregion: Fix memregion_free() fallback definition Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 040/112] video: of_display_timing.h: include errno.h Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 041/112] fscache: Fix invalidation/lookup race Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 042/112] fscache: Fix if condition in fscache_wait_on_volume_collision() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 043/112] powerpc/powernv: delay rng platform device creation until later in boot Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 044/112] net: dsa: qca8k: reset cpu port on MTU change Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 045/112] ARM: meson: Fix refcount leak in meson_smp_prepare_cpus Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 046/112] pinctrl: sunxi: a83t: Fix NAND function name for some pins Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 047/112] srcu: Tighten cleanup_srcu_struct() GP checks Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 048/112] ASoC: rt711: Add endianness flag in snd_soc_component_driver Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 049/112] ASoC: rt711-sdca: " Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 050/112] ASoC: codecs: rt700/rt711/rt711-sdca: resume bus/codec in .set_jack_detect Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 051/112] ASoC: SOF: ipc3-topology: Move and correct size checks in sof_ipc3_control_load_bytes() Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 052/112] ASoC: SOF: Intel: hda: Fix compressed stream position tracking Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 053/112] arm64: dts: qcom: sm8450: fix interconnects property of UFS node Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 054/112] arm64: dts: qcom: msm8994: Fix CPU6/7 reg values Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 055/112] arm64: dts: qcom: sdm845: use dispcc AHB clock for mdss node Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 056/112] ARM: mxs_defconfig: Enable the framebuffer Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 057/112] arm64: dts: imx8mp-evk: correct mmc pad settings Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 058/112] arm64: dts: imx8mp-evk: correct the uart2 pinctl value Greg Kroah-Hartman
2022-07-11  9:06 ` [PATCH 5.18 059/112] arm64: dts: imx8mp-evk: correct gpio-led pad settings Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 060/112] arm64: dts: imx8mp-evk: correct vbus " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 061/112] arm64: dts: imx8mp-evk: correct eqos " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 062/112] arm64: dts: imx8mp-evk: correct I2C5 " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 063/112] arm64: dts: imx8mp-evk: correct I2C1 " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 064/112] arm64: dts: imx8mp-evk: correct I2C3 " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 065/112] arm64: dts: imx8mp-phyboard-pollux-rdk: correct uart " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 066/112] arm64: dts: imx8mp-phyboard-pollux-rdk: correct eqos " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 067/112] arm64: dts: imx8mp-phyboard-pollux-rdk: correct i2c2 & mmc settings Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 068/112] pinctrl: sunxi: sunxi_pconf_set: use correct offset Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 069/112] arm64: dts: qcom: msm8992-*: Fix vdd_lvs1_2-supply typo Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 070/112] ARM: at91: pm: use proper compatible for sama5d2s rtc Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 071/112] ARM: at91: pm: use proper compatibles for sam9x60s rtc and rtt Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 072/112] ARM: at91: pm: use proper compatibles for sama7g5s " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 073/112] ARM: dts: at91: sam9x60ek: fix eeprom compatible and size Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 074/112] ARM: dts: at91: sama5d2_icp: fix eeprom compatibles Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 075/112] ARM: at91: fix soc detection for SAM9X60 SiPs Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 076/112] xsk: Clear page contiguity bit when unmapping pool Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 077/112] i2c: piix4: Fix a memory leak in the EFCH MMIO support Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 078/112] i40e: Fix dropped jumbo frames statistics Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 079/112] i40e: Fix VFs MAC Address change on VM Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 080/112] ARM: dts: stm32: add missing usbh clock and fix clk order on stm32mp15 Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 081/112] ibmvnic: Properly dispose of all skbs during a failover Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 082/112] selftests: forwarding: fix flood_unicast_test when h2 supports IFF_UNICAST_FLT Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 083/112] selftests: forwarding: fix learning_test when h1 " Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 084/112] selftests: forwarding: fix error message in learning_test Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 085/112] ACPI: CPPC: Check _OSC for flexible address space Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 086/112] ACPI: bus: Set CPPC _OSC bits for all and when CPPC_LIB is supported Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 087/112] ACPI: CPPC: Only probe for _CPC if CPPC v2 is acked Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 088/112] ACPI: CPPC: Dont require _OSC if X86_FEATURE_CPPC is supported Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 089/112] net/mlx5e: Fix matchall police parameters validation Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 090/112] mptcp: Avoid acquiring PM lock for subflow priority changes Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 091/112] mptcp: Acquire the subflow socket lock before modifying MP_PRIO flags Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 092/112] mptcp: fix local endpoint accounting Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 093/112] r8169: fix accessing unset transport header Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 094/112] i2c: cadence: Unregister the clk notifier in error path Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 095/112] net/sched: act_api: Add extack to offload_act_setup() callback Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 096/112] net/sched: act_police: Add extack messages for offload failure Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 097/112] net/sched: act_police: allow continue action offload Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 098/112] dmaengine: imx-sdma: Allow imx8m for imx7 FW revs Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 099/112] dmaengine: imx-sdma: only restart cyclic channel when enabled Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 100/112] misc: rtsx_usb: fix use of dma mapped buffer for usb bulk transfer Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 101/112] misc: rtsx_usb: use separate command and response buffers Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 102/112] misc: rtsx_usb: set return value in rsp_buf alloc err path Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 103/112] dmaengine: dw-axi-dmac: Fix RMW on channel suspend register Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 104/112] dt-bindings: dma: allwinner,sun50i-a64-dma: Fix min/max typo Greg Kroah-Hartman
2022-07-11  9:07 ` Greg Kroah-Hartman [this message]
2022-07-11  9:07 ` [PATCH 5.18 106/112] dmaengine: pl330: Fix lockdep warning about non-static key Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 107/112] dmaengine: lgm: Fix an error handling path in intel_ldma_probe() Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 108/112] dmaengine: at_xdma: handle errors of at_xdmac_alloc_desc() correctly Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 109/112] dmaengine: ti: Fix refcount leak in ti_dra7_xbar_route_allocate Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 110/112] dmaengine: qcom: bam_dma: fix runtime PM underflow Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 111/112] dmaengine: ti: Add missing put_device in ti_dra7_xbar_route_allocate Greg Kroah-Hartman
2022-07-11  9:07 ` [PATCH 5.18 112/112] dmaengine: idxd: force wq context cleanup on device disable path Greg Kroah-Hartman
2022-07-11 15:25 ` [PATCH 5.18 000/112] 5.18.11-rc1 review Holger Hoffstätte
2022-07-11 18:58 ` Florian Fainelli
2022-07-11 20:55 ` Ron Economos
2022-07-12  1:13 ` Guenter Roeck
2022-07-12  2:34 ` Shuah Khan
2022-07-12  3:22 ` Naresh Kamboju
2022-07-12  7:14 ` Rudi Heitbaum
2022-07-12 12:51 ` Bagas Sanjaya
2022-07-12 14:40 ` Sudip Mukherjee (Codethink)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220711090552.550441998@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ieitayie@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).