Re: [PATCH] mfd: ls2kbmc: Fix iomem pointer handling in video mode parsing

From: Huacai Chen

Date: Fri Jun 19 2026 - 03:12:43 EST


Hi, Binbin,

On Tue, Jun 16, 2026 at 7:56 PM Binbin Zhou <zhoubinbin@xxxxxxxxxxx> wrote:
>
> Use pointers annotated with the __iomem marker for all iomem map calls,
> and creates a local copy of the mapped IO memory for future access in
> the code. memcpy_fromio() and memcpy_toio() are used to read/write data
> from/to mapped IO memory
>
> Fixes: 0d64f6d1ffe9 ("mfd: ls2kbmc: Introduce Loongson-2K BMC core driver")
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202603021730.Yy3QXYTw-lkp@xxxxxxxxx/
> Closes: https://lore.kernel.org/oe-kbuild-all/202606120639.WG6eb8VU-lkp@xxxxxxxxx/
> Signed-off-by: Binbin Zhou <zhoubinbin@xxxxxxxxxxx>
> ---
> drivers/mfd/ls2k-bmc-core.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/ls2k-bmc-core.c b/drivers/mfd/ls2k-bmc-core.c
> index 408056bfb2fe..c40b1a7c4ea4 100644
> --- a/drivers/mfd/ls2k-bmc-core.c
> +++ b/drivers/mfd/ls2k-bmc-core.c
> @@ -427,14 +427,21 @@ static int ls2k_bmc_init(struct ls2k_bmc_ddata *ddata)
> */
> static int ls2k_bmc_parse_mode(struct pci_dev *pdev, struct simplefb_platform_data *pd)
> {
> - char *mode;
> + void *buf __free(kfree) = NULL;
> + void __iomem *base;
> int depth, ret;
> + char *mode;
>
> /* The last 16M of PCI BAR0 is used to store the resolution string. */
> - mode = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0) + SZ_16M, SZ_16M);
> - if (!mode)
> + base = devm_ioremap(&pdev->dev, pci_resource_start(pdev, 0) + SZ_16M, SZ_16M);
> + if (!base)
> + return -ENOMEM;
> +
> + buf = kmalloc(SZ_16M, GFP_KERNEL);
> + if (!buf)
> return -ENOMEM;
>
> + mode = (char *)buf;
I think you miss "memcpy_fromio(buf, base, SZ_16M)" here.

Huacai

> /* The resolution field starts with the flag "video=". */
> if (!strncmp(mode, "video=", 6))
> mode = mode + 6;
>
> base-commit: b07f7904e0523170856876e4412be852377d492a
> --
> 2.52.0
>