linux/drivers/dma/idxd
Dan Carpenter 39aaa33744 dmaengine: idxd: Fix double free in idxd_setup_wqs()
The clean up in idxd_setup_wqs() has had a couple bugs because the error
handling is a bit subtle.  It's simpler to just re-write it in a cleaner
way.  The issues here are:

1) If "idxd->max_wqs" is <= 0 then we call put_device(conf_dev) when
   "conf_dev" hasn't been initialized.
2) If kzalloc_node() fails then again "conf_dev" is invalid.  It's
   either uninitialized or it points to the "conf_dev" from the
   previous iteration so it leads to a double free.

It's better to free partial loop iterations within the loop and then
the unwinding at the end can handle whole loop iterations.  I also
renamed the labels to describe what the goto does and not where the goto
was located.

Fixes: 3fd2f4bc01 ("dmaengine: idxd: fix memory leak in error handling path of idxd_setup_wqs")
Reported-by: Colin Ian King <colin.i.king@gmail.com>
Closes: https://lore.kernel.org/all/20250811095836.1642093-1-colin.i.king@gmail.com/
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/aJnJW3iYTDDCj9sk@stanley.mountain
Signed-off-by: Vinod Koul <vkoul@kernel.org>
History 2025-08-20 23:02:04 +05:30
..
bus.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
cdev.c dmaengine updates for v6.16 2025-06-05 08:49:30 -07:00
compat.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
debugfs.c dmaengine: idxd: Convert spinlock to mutex to lock evl workqueue 2024-04-07 13:31:44 +05:30
defaults.c dmaengine: idxd: Add support for device/wq defaults 2023-12-15 17:52:53 +08:00
device.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
dma.c dmaengine: add channel device name to channel registration 2024-06-11 23:55:34 +05:30
idxd.h dmaengine: idxd: Remove unused pointer and macro 2025-05-14 16:00:30 +01:00
init.c dmaengine: idxd: Fix double free in idxd_setup_wqs() 2025-08-20 23:02:04 +05:30
irq.c dmaengine: idxd: Enable Function Level Reset (FLR) for halt 2024-12-24 16:08:05 +05:30
Makefile module: Convert default symbol namespace to string literal 2024-12-03 08:22:25 -08:00
perfmon.c dmaengine updates for v6.12 2024-09-23 14:08:08 -07:00
perfmon.h dmaengine: idxd: Add IDXD performance monitor support 2021-04-25 21:46:12 +05:30
registers.h dmaengine: idxd: Remove __packed from structures 2025-06-27 10:54:25 -07:00
submit.c module: Convert symbol namespace to string literal 2024-12-02 11:34:44 -08:00
sysfs.c dmaengine: idxd: Narrow the restriction on BATCH to ver. 1 only 2025-05-14 15:29:04 +01:00