linux/drivers/s390
Salah Triki b1d4e6fb24 s390/cio: Fix device lifecycle handling in css_alloc_subchannel()
[ Upstream commit f65c75b0b9 ]

`css_alloc_subchannel()` calls `device_initialize()` before setting up
the DMA masks. If `dma_set_coherent_mask()` or `dma_set_mask()` fails,
the error path frees the subchannel structure directly, bypassing
the device model reference counting.

Once `device_initialize()` has been called, the embedded struct device
must be released via `put_device()`, allowing the release callback to
free the container structure.

Fix the error path by dropping the initial device reference with
`put_device()` instead of calling `kfree()` directly.

This ensures correct device lifetime handling and avoids potential
use-after-free or double-free issues.

Fixes: e5dcf0025d ("s390/css: move subchannel lock allocation")
Signed-off-by: Salah Triki <salah.triki@gmail.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-04 07:19:23 -05:00
..
block s390/dasd: fix error recovery leading to data corruption on ESE devices 2024-09-04 13:23:15 +02:00
char s390/tty: Fix a potential memory leak bug 2025-05-02 07:44:34 +02:00
cio s390/cio: Fix device lifecycle handling in css_alloc_subchannel() 2026-03-04 07:19:23 -05:00
crypto s390/ap: Don't leak debug feature files if AP instructions are not available 2026-01-19 13:09:24 +01:00
net s390/ctcm: Fix double-kfree 2025-12-07 06:09:31 +09:00
scsi scsi: s390: zfcp: Ensure synchronous unit_add 2025-06-27 11:05:34 +01:00
virtio virtio/s390: get rid of open-coded kvm hypercall 2021-06-28 11:18:28 +02:00
Makefile s390: remove pointless drivers-y in drivers/s390/Makefile 2019-09-16 13:21:51 +02:00