From: sashiko-bot@kernel.org
To: "Ali Ahmet Memis" <ali@iusegentoo.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 5/5] scsi: elx: efct: destroy the mailbox pools when setup fails
Date: Thu, 06 Aug 2026 19:41:43 +0000 [thread overview]
Message-ID: <20260806194144.5A9661F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806192345.328621-6-ali@iusegentoo.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [Medium] The patch misses clearing `hw->hw_setup_called` on the first error path, contradicting the commit message claims.
Pre-existing issues:
- [High] Failing to allocate `wqe_buffs` causes a memory leak of all `hw->io[i]` objects.
- [High] The `sli_setup()` function leaks DMA memory and bitmaps on its internal error paths.
- [High] Probe failure paths in `efct_pci_probe()` fail to invoke `efct_hw_teardown()`, leaking hardware setup allocations.
- [Medium] `efct_hw_parse_filter()` leaks a dynamically allocated string when provided an empty string.
--
--- Patch [5]: [PATCH 5/5] scsi: elx: efct: destroy the mailbox pools when setup fails ---
commit fb169760590ca6bbaa661961e72dbf1d2bbfb5e8
Author: Ali Ahmet Memis <ali@iusegentoo.com>
scsi: elx: efct: destroy the mailbox pools when setup fails
This commit fixes a memory leak in the error paths of efct_hw_setup().
It ensures mempools are properly destroyed and hw_setup_called is cleared
if initialization fails.
> diff --git a/drivers/scsi/elx/efct/efct_hw.c b/drivers/scsi/elx/efct/efct_hw.c
> index d645ce256b8aa..efbf29d3386e9 100644
> --- a/drivers/scsi/elx/efct/efct_hw.c
> +++ b/drivers/scsi/elx/efct/efct_hw.c
[ ... ]
> /* Create mailbox command ctx pool */
> hw->cmd_ctx_pool = mempool_create_kmalloc_pool(EFCT_CMD_CTX_POOL_SZ,
> sizeof(struct efct_command_ctx));
> if (!hw->cmd_ctx_pool) {
> efc_log_err(hw->os, "failed to allocate mailbox buffer pool\n");
> return -EIO;
[Severity: Medium]
The commit message states that hw_setup_called is cleared on the way out
so that a later call does not take the early return. However, if this first
allocation fails, we return directly without clearing it.
Should this path also jump to a label that clears hw->hw_setup_called to
prevent handing the caller a half-configured hw structure on subsequent
calls?
> }
>
> /* Create mailbox request ctx pool for library callback */
> hw->mbox_rqst_pool = mempool_create_kmalloc_pool(EFCT_CMD_CTX_POOL_SZ,
> sizeof(struct efct_mbox_rqst_ctx));
> if (!hw->mbox_rqst_pool) {
> efc_log_err(hw->os, "failed to allocate mbox request pool\n");
> - return -EIO;
> + goto free_cmd_ctx_pool;
> }
[ ... ]
> +free_mbox_rqst_pool:
> + mempool_destroy(hw->mbox_rqst_pool);
> + hw->mbox_rqst_pool = NULL;
> +free_cmd_ctx_pool:
> + mempool_destroy(hw->cmd_ctx_pool);
> + hw->cmd_ctx_pool = NULL;
> + hw->hw_setup_called = false;
> +
> + return -EIO;
> }
[Severity: High]
This is a pre-existing issue, but does efct_hw_setup_io() leak memory
if the wqe_buffs allocation fails?
drivers/scsi/elx/efct/efct_hw.c:efct_hw_setup_io() {
...
if (!hw->wqe_buffs) {
kfree(hw->io);
return -ENOMEM;
}
...
}
The error path frees the hw->io array but appears to fail to free the
individual objects pointed to by the array, leaking them permanently.
Could this be updated to clean up the inner objects?
[Severity: High]
This is a pre-existing issue, but does sli_setup() leak DMA memory on
its internal error paths?
drivers/scsi/elx/libefc_sli/sli4.c:sli_setup() {
...
sli4->bmbx.virt = dma_alloc_coherent(&pdev->dev, sli4->bmbx.size, ...);
...
if (sli_request_features(sli4, &sli4->features, true))
return -EIO;
...
}
When sli_setup() fails during subsequent initializations like
sli_request_features(), it returns directly without freeing the DMA memory
allocated earlier for sli4->bmbx.virt and sli4->vpd_data.virt. Since the caller
efct_hw_setup() has no way to clean up partial allocations, does this permanently
leak DMA memory?
[Severity: High]
This is a pre-existing issue, but do the probe failure paths in
efct_pci_probe() leak the hardware setup allocations?
drivers/scsi/elx/efct/efct_driver.c:efct_pci_probe() {
...
attach_out:
efct_teardown_msix(efct);
dma_mask_out:
pci_set_drvdata(pdev, NULL);
for (i = 0; i < EFCT_PCI_MAX_REGS; i++) {
if (efct->reg[i])
iounmap(efct->reg[i]);
}
efct_device_free(efct);
}
The probe routine invokes efct_hw_setup() which allocates mempools and DMA
memory. If a subsequent step fails, the probe routine branches to attach_out
or dma_mask_out, which calls efct_device_free() but omits calling
efct_hw_teardown(). Does this result in all hardware allocations and
mempools being permanently leaked?
[Severity: Medium]
This is a pre-existing issue, but does efct_hw_parse_filter() leak a
dynamically allocated string when provided an empty string?
drivers/scsi/elx/efct/efct_hw.c:efct_hw_parse_filter() {
...
p = kstrdup(value, GFP_KERNEL);
if (!p || !*p) {
efc_log_err(hw->os, "p is NULL\n");
return -ENOMEM;
}
...
}
If value is an empty string, kstrdup() allocates a 1-byte buffer containing
just a null terminator. The subsequent check !*p evaluates to true, and the
function returns -ENOMEM without freeing p. Should this call kfree(p) before
returning?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806192345.328621-1-ali@iusegentoo.com?part=5
next prev parent reply other threads:[~2026-08-06 19:41 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 19:23 [PATCH 0/5] scsi: elx: efct: fix resources stranded on failure paths Ali Ahmet Memis
2026-08-06 19:23 ` [PATCH 1/5] scsi: elx: efct: check the HW state before allocating an HIO Ali Ahmet Memis
2026-08-06 19:44 ` sashiko-bot
2026-08-06 19:23 ` [PATCH 2/5] scsi: elx: efct: free the HIO when the WQE cannot be built Ali Ahmet Memis
2026-08-06 19:54 ` sashiko-bot
2026-08-06 19:23 ` [PATCH 3/5] scsi: elx: efct: free the request tag when the send frame WQE fails Ali Ahmet Memis
2026-08-06 19:50 ` sashiko-bot
2026-08-06 19:23 ` [PATCH 4/5] scsi: elx: efct: free the RQ buffers already allocated when one fails Ali Ahmet Memis
2026-08-06 20:00 ` sashiko-bot
2026-08-06 19:23 ` [PATCH 5/5] scsi: elx: efct: destroy the mailbox pools when setup fails Ali Ahmet Memis
2026-08-06 19:41 ` sashiko-bot [this message]
2026-08-06 20:22 ` [PATCH v2 0/5] scsi: elx: efct: fix resources stranded on failure paths Ali Ahmet Memis
2026-08-06 20:22 ` [PATCH v2 1/5] scsi: elx: efct: check the HW state before allocating an HIO Ali Ahmet Memis
2026-08-06 20:59 ` sashiko-bot
2026-08-06 20:22 ` [PATCH v2 2/5] scsi: elx: efct: free the HIO when the WQE cannot be built Ali Ahmet Memis
2026-08-06 20:52 ` sashiko-bot
2026-08-06 20:22 ` [PATCH v2 3/5] scsi: elx: efct: free the request tag when the send frame WQE fails Ali Ahmet Memis
2026-08-06 20:41 ` sashiko-bot
2026-08-06 20:22 ` [PATCH v2 4/5] scsi: elx: efct: free the RQ buffers already allocated when one fails Ali Ahmet Memis
2026-08-06 20:38 ` sashiko-bot
2026-08-06 20:22 ` [PATCH v2 5/5] scsi: elx: efct: destroy the mailbox pools when setup fails Ali Ahmet Memis
2026-08-06 20:57 ` sashiko-bot
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=20260806194144.5A9661F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ali@iusegentoo.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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).