* [PATCH 0/1] zfcp bugfix for 7.2
@ 2026-07-20 7:27 Nihar Panda
2026-07-20 7:27 ` [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req Nihar Panda
0 siblings, 1 reply; 4+ messages in thread
From: Nihar Panda @ 2026-07-20 7:27 UTC (permalink / raw)
To: James E . J . Bottomley, Martin K . Petersen
Cc: linux-scsi, linux-s390, Heiko Carstens, Vasily Gorbik ,
Alexander Gordeev, Christian Borntraeger , Nihar Panda
Hi Martin and James,
we have a zfcp bugfix that address memory leak in zfcp.
It would be great if this could be included in v7.2 release.
Benjamin Block (1):
fix memory leak during adapter release by destroying gid_pn_req
drivers/s390/scsi/zfcp_aux.c | 1 +
1 file changed, 1 insertion(+)
--
2.53.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req
2026-07-20 7:27 [PATCH 0/1] zfcp bugfix for 7.2 Nihar Panda
@ 2026-07-20 7:27 ` Nihar Panda
2026-07-20 7:40 ` sashiko-bot
0 siblings, 1 reply; 4+ messages in thread
From: Nihar Panda @ 2026-07-20 7:27 UTC (permalink / raw)
To: James E . J . Bottomley, Martin K . Petersen
Cc: linux-scsi, linux-s390, Heiko Carstens, Vasily Gorbik ,
Alexander Gordeev, Christian Borntraeger , Nihar Panda
From: Benjamin Block <bblock@linux.ibm.com>
When releasing an adapter we don't free the mempool `gid_pn_req` that is
allocated during the enqueue. This leaks memory:
unreferenced object 0xd8d29297de700 (size 256):
comm "(udev-worker)", pid 2105, jiffies 4294945794
hex dump (first 32 bytes):
00 00 00 00 de ad 4e ad ff ff ff ff 00 00 00 00 ......N.........
ff ff ff ff ff ff ff ff 00 0d c4 5f 67 9d 99 e0 ..........._g...
backtrace (crc 4a5b5da2):
[<000dc45f64da418c>] kmemleak_alloc+0x6c/0xa0
[<000dc45f62b430aa>] __kmalloc_cache_node_noprof+0x36a/0x4d0
[<000dc45f629a535a>] mempool_create_node_noprof+0xaa/0x150
[<000dc45ee2c065e6>] zfcp_allocate_low_mem_buffers+0x96/0x370 [zfcp]
[<000dc45ee2c070f8>] zfcp_adapter_enqueue+0x598/0xd40 [zfcp]
[<000dc45ee2c08eb0>] zfcp_ccw_set_online+0x160/0x210 [zfcp]
[<000dc45f643d4762>] ccw_device_set_online+0x232/0xd80
[<000dc45f643d53d4>] online_store_recog_and_online+0x124/0x390
[<000dc45f643d8238>] online_store+0x298/0x5b0
[<000dc45f62eb0a04>] kernfs_fop_write_iter+0x2c4/0x480
[<000dc45f62c81150>] new_sync_write+0x370/0x4b0
[<000dc45f62c87abe>] vfs_write+0x43e/0x5b0
[<000dc45f62c87ff4>] ksys_write+0x114/0x1f0
[<000dc45f621c4a16>] do_syscall+0x2f6/0x430
[<000dc45f64d9d5d8>] __do_syscall+0xc8/0x1c0
[<000dc45f64dc2224>] system_call+0x74/0xa0
Fix this by destroying the mempool during the adapter's release.
Fixes: 799b76d09aee ("[SCSI] zfcp: Decouple gid_pn requests from erp")
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Tested-by: M Nikhil <nikh1092@linux.ibm.com>
Acked-by: M Nikhil <nikh1092@linux.ibm.com>
Reviewed-by: Chinmaya Kajagar <chinmayk@linux.ibm.com>
Reviewed-by: Nihar Panda <niharp@linux.ibm.com>
---
drivers/s390/scsi/zfcp_aux.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 8ff7db7921b5..fea573e00f9d 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -253,6 +253,7 @@ static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
static void zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
{
mempool_destroy(adapter->pool.erp_req);
+ mempool_destroy(adapter->pool.gid_pn_req);
mempool_destroy(adapter->pool.scsi_req);
mempool_destroy(adapter->pool.scsi_abort);
mempool_destroy(adapter->pool.qtcb_pool);
--
2.53.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req
2026-07-20 7:27 ` [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req Nihar Panda
@ 2026-07-20 7:40 ` sashiko-bot
2026-07-20 7:55 ` Nihar Ranjan Panda
0 siblings, 1 reply; 4+ messages in thread
From: sashiko-bot @ 2026-07-20 7:40 UTC (permalink / raw)
To: Nihar Panda
Cc: Heiko Carstens, Vasily Gorbik, linux-scsi, linux-s390,
Alexander Gordeev
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The error path in `zfcp_adapter_enqueue()` calls `zfcp_erp_thread_kill()` which unconditionally passes `adapter->erp_thread` to `kthread_stop()`. If adapter initialization fails before the thread is created (e.g., during `zfcp_allocate_low_mem_buffers()`), this results in a kernel panic because `kthread_stop()` does not handle NULL pointers.
--
--- Patch [1]: [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req ---
commit 5b4668bd066d14a43f77f6f0301f8c98cbb5069c
Author: Benjamin Block <bblock@linux.ibm.com>
fix memory leak during adapter release by destroying gid_pn_req
When releasing an adapter we don't free the mempool gid_pn_req that is
allocated during the enqueue. This fixes the memory leak by destroying the
mempool during the adapter's release.
> diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
> index 8ff7db7921b5a..fea573e00f9df 100644
> --- a/drivers/s390/scsi/zfcp_aux.c
> +++ b/drivers/s390/scsi/zfcp_aux.c
> @@ -253,6 +253,7 @@ static int zfcp_allocate_low_mem_buffers(struct zfcp_adapter *adapter)
> static void zfcp_free_low_mem_buffers(struct zfcp_adapter *adapter)
> {
> mempool_destroy(adapter->pool.erp_req);
> + mempool_destroy(adapter->pool.gid_pn_req);
[Severity: High]
This is a pre-existing issue, but if memory allocation fails during adapter
setup, could this lead to a kernel panic?
In zfcp_adapter_enqueue(), if zfcp_allocate_low_mem_buffers() returns -ENOMEM,
the code jumps to the failed label and unconditionally calls
zfcp_erp_thread_kill():
drivers/s390/scsi/zfcp_aux.c:zfcp_adapter_enqueue() {
...
failed:
/* TODO: make this more fine-granular */
cancel_delayed_work_sync(&adapter->scan_work);
cancel_work_sync(&adapter->stat_work);
cancel_work_sync(&adapter->ns_up_work);
cancel_work_sync(&adapter->version_change_lost_work);
zfcp_destroy_adapter_work_queue(adapter);
zfcp_fc_wka_ports_force_offline(adapter->gs);
zfcp_scsi_adapter_unregister(adapter);
zfcp_erp_thread_kill(adapter);
...
}
However, if the thread was never created, adapter->erp_thread is NULL.
zfcp_erp_thread_kill() unconditionally passes it to kthread_stop():
drivers/s390/scsi/zfcp_erp.c:zfcp_erp_thread_kill() {
kthread_stop(adapter->erp_thread);
adapter->erp_thread = NULL;
}
Since kthread_stop() does not handle NULL pointers, will this result in a
NULL pointer dereference?
> mempool_destroy(adapter->pool.scsi_req);
> mempool_destroy(adapter->pool.scsi_abort);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260720072736.3381816-2-niharp@linux.ibm.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req
2026-07-20 7:40 ` sashiko-bot
@ 2026-07-20 7:55 ` Nihar Ranjan Panda
0 siblings, 0 replies; 4+ messages in thread
From: Nihar Ranjan Panda @ 2026-07-20 7:55 UTC (permalink / raw)
To: sashiko-reviews
Cc: Heiko Carstens, Vasily Gorbik, linux-scsi, linux-s390,
Alexander Gordeev
Hi Martin and James,
The bug reported by the sashiko bot is a pre-existing issue and was not introduced by this fix.
Please allow this fix to go upstream. We will create an EWM ticket to address the bot's finding in a separate patch.
On 20/07/26 1:10 pm, sashiko-bot@kernel.org wrote:
> Pre-existing issues:
> - [High] The error path in `zfcp_adapter_enqueue()` calls `zfcp_erp_thread_kill()` which unconditionally passes `adapter->erp_thread` to `kthread_stop()`. If adapter initialization fails before the thread is created (e.g., during `zfcp_allocate_low_mem_buffers()`), this results in a kernel panic because `kthread_stop()` does not handle NULL pointers.
> --
>
> --- Patch [1]: [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req ---
> commit 5b4668bd066d14a43f77f6f0301f8c98cbb5069c
> Author: Benjamin Block <bblock@linux.ibm.com>
>
> fix memory leak during adapter release by destroying gid_pn_req
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-20 7:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 7:27 [PATCH 0/1] zfcp bugfix for 7.2 Nihar Panda
2026-07-20 7:27 ` [PATCH 1/1] fix memory leak during adapter release by destroying gid_pn_req Nihar Panda
2026-07-20 7:40 ` sashiko-bot
2026-07-20 7:55 ` Nihar Ranjan Panda
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.