dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: yuebingkun <yuebingkun@kylinos.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] fbdev: platinumfb: add error checking for ioremap calls
Date: Mon, 17 Aug 2026 06:44:58 +0000	[thread overview]
Message-ID: <20260817064459.361DD1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260817063637.306865-1-yuebingkun@kylinos.cn>

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

Pre-existing issues:
- [High] The return value of `request_mem_region` for `cmap_regs_phys` is ignored, and the error path unconditionally calls `release_mem_region` on it.
--

--- Patch [1]: [PATCH] fbdev: platinumfb: add error checking for ioremap calls ---
commit 71a977c44688a9c49d5d28cb513b56fa5a810a1d
Author: yuebingkun <yuebingkun@kylinos.cn>

fbdev: platinumfb: add error checking for ioremap calls

This commit adds error checking for ioremap() and ioremap_wt() calls in
platinumfb_probe() to prevent NULL pointer dereferences. It also transitions
the function to use goto-based cleanup for handling initialization failures.

> diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
> index a08d955d9b439..f74c937c839f8 100644
> --- a/drivers/video/fbdev/platinumfb.c
> +++ b/drivers/video/fbdev/platinumfb.c

[ ... ]

> @@ -623,13 +638,22 @@ static int platinumfb_probe(struct platform_device* odev)
>  	dev_set_drvdata(&odev->dev, info);
>  
>  	rc = platinum_init_fb(info);
> -	if (rc != 0) {
> -		iounmap(pinfo->frame_buffer);
> -		iounmap(pinfo->platinum_regs);
> -		iounmap(pinfo->cmap_regs);
> -		framebuffer_release(info);
> -	}
> +	if (rc != 0)
> +		goto err_unmap_cmap;
> +
> +	return 0;
>  
> +err_unmap_cmap:
> +	iounmap(pinfo->cmap_regs);
> +err_release_cmap:
> +	release_mem_region(pinfo->cmap_regs_phys, 0x1000);

[Severity: High]
This is a pre-existing issue, but by adding this new error path, the code
propagates an unsafe assumption.

Earlier in platinumfb_probe(), the return value of request_mem_region()
is ignored:

	request_mem_region(pinfo->cmap_regs_phys, 0x1000, "platinumfb cmap");
	pinfo->cmap_regs = ioremap(pinfo->cmap_regs_phys, 0x1000);

If request_mem_region() fails (for instance, if the region is already
claimed), execution continues. If a subsequent step like ioremap() or
platinum_init_fb() then fails, the code will jump to this newly added
err_release_cmap label and unconditionally release the region.

Because __release_region() searches by address and doesn't verify the caller,
could this forcefully free an I/O memory region that actually belongs to
another driver, potentially leading to resource tree corruption or a
use-after-free?

> +err_unmap_regs:
> +	iounmap(pinfo->platinum_regs);
> +err_unmap_fb:
> +	iounmap(pinfo->frame_buffer);

[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260817063637.306865-1-yuebingkun@kylinos.cn?part=1

  reply	other threads:[~2026-08-17  6:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17  6:36 [PATCH] fbdev: platinumfb: add error checking for ioremap calls yuebingkun
2026-08-17  6:44 ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-17  5:56 yuebingkun
2026-08-17  6:28 ` Markus Elfring

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=20260817064459.361DD1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yuebingkun@kylinos.cn \
    /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