Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Markus Elfring" <Markus.Elfring@web.de>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: message: fusion: Use more common error handling code in mpt_attach()
Date: Wed, 17 Jun 2026 20:42:33 +0000	[thread overview]
Message-ID: <20260617204234.3E1E31F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <645f850d-bd48-4c72-97e4-5771e247de8f@web.de>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Data race on global `ioc_list` and static `mpt_ids` variables during concurrent device probing.
- [High] DMA memory leak on device initialization failure.
--

commit 4e8cbd0babcc92bd561c86ab647d8b47fc357dc0
Author: Markus Elfring <elfring@users.sourceforge.net>

scsi: message: fusion: Use more common error handling code in mpt_attach()

Use an existing label once more so that a bit of exception handling can be
better reused at the end of this function implementation.

> diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
> index 3a431ffd3e2eb..c2c5a25cf5aec 100644
> --- a/drivers/message/fusion/mptbase.c
> +++ b/drivers/message/fusion/mptbase.c
> @@ -2014,9 +2014,7 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
>  
>  		destroy_workqueue(ioc->reset_work_q);
>  		ioc->reset_work_q = NULL;
> -
> -		kfree(ioc);
> -		return r;
> +		goto out_free_ioc;

[Severity: High]
This isn't a bug introduced by this patch, but does this error path
permanently leak DMA memory?

If mpt_do_ioc_recovery() fails, it bails out to this error path that cleans
up some resources before jumping to out_free_ioc to free the ioc struct.

However, mpt_do_ioc_recovery() internally calls PrimeIocFifos(), which
allocates large DMA coherent buffers (saved in ioc->alloc and
ioc->sense_buf_pool). Because mpt_adapter_disable(ioc) or
mpt_adapter_dispose(ioc) is never called on this error path, these DMA
allocations appear to be leaked.

[Severity: High]
This is a pre-existing issue, but is there a data race when modifying global
variables during concurrent device probing?

The mpt_attach() function is called during PCI device probing. The Linux
driver core does not serialize probe routines across different devices; it
only holds a per-device lock. If multiple MPT controllers are bound
concurrently (e.g., via concurrent sysfs bind writes), multiple threads
could modify the static mpt_ids counter and append to the global ioc_list
simultaneously without synchronization:

mpt_attach() {
    ...
    ioc->id = mpt_ids++;
    ...
    list_add_tail(&ioc->list, &ioc_list);
    ...
}

Could this lead to list corruption and kernel crashes?

>  	}
>  
>  	/* call per device driver probe entry point */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/645f850d-bd48-4c72-97e4-5771e247de8f@web.de?part=1

      reply	other threads:[~2026-06-17 20:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-17 18:34 [PATCH] scsi: message: fusion: Use more common error handling code in mpt_attach() Markus Elfring
2026-06-17 20:42 ` sashiko-bot [this message]

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=20260617204234.3E1E31F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Markus.Elfring@web.de \
    --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