From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v3] PCI: mediatek: Fix integer truncation and handle oversized resources
Date: Wed, 30 Sep 2026 11:52:39 +0000 [thread overview]
Message-ID: <20260930115240.516471F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260930114218.2655-1-sreekuttan2156239@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] PCI: mediatek: build failure due to invalid port->dev access
--
commit 40759eff660bb6850cba10f5b37e699dc72c75cb
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
PCI: mediatek: Fix integer truncation and handle oversized resources
This commit fixes integer truncation issues when calculating the size order
for AHB to PCIe translation windows by using fls64(). It also adds checks
to return -EINVAL if the resource size exceeds the maximum supported 31-bit
window order.
> diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c
> index 3a3e91cd0c211..1b0ab5a2c73cc 100644
> --- a/drivers/pci/controller/pcie-mediatek.c
> +++ b/drivers/pci/controller/pcie-mediatek.c
[ ... ]
> @@ -753,8 +756,18 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port)
> mtk_pcie_enable_msi(port);
>
> /* Set AHB to PCIe translation windows */
> + size = resource_size(mem);
> + if (!size)
> + return -EINVAL;
> +
> + size_order = fls64(size - 1);
> + if (size_order > 31) {
> + dev_err(port->dev, "Memory resource size too large: %pa\n", &size);
[Severity: Low]
Does this code compile? Looking at the definition of struct mtk_pcie_port,
it does not appear to have a dev member.
Could this be causing a build failure, and should it use port->pcie->dev
instead?
> + return -EINVAL;
> + }
> +
> val = lower_32_bits(mem->start) |
> - AHB2PCIE_SIZE(fls(resource_size(mem)));
> + AHB2PCIE_SIZE(size_order);
> writel(val, port->base + PCIE_AHB_TRANS_BASE0_L);
[ ... ]
> @@ -829,8 +844,18 @@ static int mtk_pcie_startup_port_en7528(struct mtk_pcie_port *port)
> mtk_pcie_enable_msi(port);
>
> /* Set AHB to PCIe translation windows */
> + size = resource_size(mem);
> + if (!size)
> + return -EINVAL;
> +
> + size_order = fls64(size - 1);
> + if (size_order > 31) {
> + dev_err(port->dev, "Memory resource size too large: %pa\n", &size);
[Severity: Low]
This looks like the same build issue here. Should this use pcie->dev,
since struct mtk_pcie_port lacks a dev member?
> + return -EINVAL;
> + }
> +
> val = lower_32_bits(mem->start) |
> - AHB2PCIE_SIZE(fls(resource_size(mem)));
> + AHB2PCIE_SIZE(size_order);
> writel(val, port->base + PCIE_AHB_TRANS_BASE0_L);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260930114218.2655-1-sreekuttan2156239@gmail.com?part=1
prev parent reply other threads:[~2026-09-30 11:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 11:42 [PATCH v3] PCI: mediatek: Fix integer truncation and handle oversized resources Sreeraj S Kurup
2026-09-30 11:52 ` 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=20260930115240.516471F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sreekuttan2156239@gmail.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