From: sashiko-bot@kernel.org
To: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
"Orgad Shaneh" <orgads@gmail.com>,
tsbogend@alpha.franken.de
Cc: dwmw2@infradead.org, ulli.kroll@googlemail.com, corbet@lwn.net,
kaloz@openwrt.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linusw@kernel.org,
nico@fluxnic.net, linux-mtd@lists.infradead.org,
linux-mips@vger.kernel.org, john@phrozen.org
Subject: Re: [PATCH 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC
Date: Sat, 10 Oct 2026 17:32:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-166778@kernel.org> (raw)
In-Reply-To: <20261010172142.2138956-4-orgads@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] mips: cavium-octeon: global state corruption on multiple flash probes
--
commit 9e242ec4162d9c7c06bd10d98f2bbfb32869d150
Author: Orgad Shaneh <orgads@gmail.com>
MIPS: Octeon: flash: use the simple map accessors without a shared eMMC
This patch updates the Cavium Octeon flash setup to use simple map accessors
when there is no shared eMMC host on the boot bus. It also changes the flash
bank width check to fail and unmap the memory if unsupported, rather than
just warning.
> diff --git a/arch/mips/cavium-octeon/flash_setup.c b/arch/mips/cavium-octeon/flash_setup.c
> index 3395acde4d60a..28fbe3d15c956 100644
> --- a/arch/mips/cavium-octeon/flash_setup.c
> +++ b/arch/mips/cavium-octeon/flash_setup.c
[ ... ]
> @@ -102,11 +113,26 @@ static int octeon_flash_probe(struct platform_device *pdev)
> flash_map.virt = ioremap(flash_map.phys, flash_map.size);
> pr_notice("Bootbus flash: Setting flash for %luMB flash at "
> "0x%08llx\n", flash_map.size >> 20, flash_map.phys);
> - WARN_ON(!map_bankwidth_supported(flash_map.bankwidth));
> - flash_map.read = octeon_flash_map_read;
> - flash_map.write = octeon_flash_map_write;
> - flash_map.copy_from = octeon_flash_map_copy_from;
> - flash_map.copy_to = octeon_flash_map_copy_to;
> + if (!map_bankwidth_supported(flash_map.bankwidth)) {
> + pr_err("Unsupported flash bank width %d\n",
> + flash_map.bankwidth);
> + iounmap(flash_map.virt);
> + return -EINVAL;
> + }
[Severity: High]
Since flash_map is a static global structure, what happens if there are
multiple flash devices probed sequentially?
The line just above this block unconditionally overwrites flash_map.virt
with a new ioremap() on each probe, which appears to leak the previous
mapping and corrupt the state of any already-registered MTD device.
If octeon_flash_probe() executes a second time and fails the bank width check
here, it calls iounmap(flash_map.virt) and returns an error. Does this unmap
operation turn the first successfully probed MTD device's shared reference
into a dangling pointer, leading to an invalid memory access when the first
device is accessed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261010172142.2138956-1-orgads@gmail.com?part=3
next prev parent reply other threads:[~2026-10-10 17:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-10 17:21 [PATCH 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-10 17:21 ` [PATCH 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-10 17:21 ` [PATCH 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-10 17:31 ` sashiko-bot
2026-10-10 17:21 ` [PATCH 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-10 17:32 ` sashiko-bot [this message]
2026-10-10 18:08 ` [PATCH v2 0/3] mtd: point() for cfi_cmdset_0002, on simple maps only Orgad Shaneh
2026-10-10 18:08 ` [PATCH v2 1/3] mtd: maps: only point() maps read through the simple accessors Orgad Shaneh
2026-10-10 18:08 ` [PATCH v2 2/3] mtd: cfi_cmdset_0002: implement point() for simple linear maps Orgad Shaneh
2026-10-10 18:18 ` sashiko-bot
2026-10-10 18:08 ` [PATCH v2 3/3] MIPS: Octeon: flash: use the simple map accessors without a shared eMMC Orgad Shaneh
2026-10-10 18:18 ` 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=sashiko-outbox-166778@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=corbet@lwn.net \
--cc=dwmw2@infradead.org \
--cc=john@phrozen.org \
--cc=kaloz@openwrt.org \
--cc=linusw@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=nico@fluxnic.net \
--cc=orgads@gmail.com \
--cc=richard@nod.at \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tsbogend@alpha.franken.de \
--cc=ulli.kroll@googlemail.com \
--cc=vigneshr@ti.com \
/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
all inboxes | Powered by JetHome®