From: sashiko-bot@kernel.org
To: oushixiong1025@163.com
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/5] fbdev: matrox: Convert to managed PCI and ioremap API
Date: Thu, 13 Aug 2026 13:02:07 +0000 [thread overview]
Message-ID: <20260813130207.C1F8E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260813125015.1097301-4-oushixiong1025@163.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Crash/UAF due to premature devres cleanup during deferred driver teardown.
--
--- Patch [4]: [PATCH 4/5] fbdev: matrox: Convert to managed PCI and ioremap API ---
commit 3f4d09fdf1478a2c901bd635a21ab3e200899c5a
Author: Shixiong Ou <oushixiong@kylinos.cn>
fbdev: matrox: Convert to managed PCI and ioremap API
This commit converts the matroxfb driver to use managed device resource
APIs such as pcim_enable_device, devm_request_mem_region, and devm_ioremap.
It removes the manual release_mem_region and iounmap calls from the remove
path and error handling.
> diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c
> index ac04a19b68492..24d312c29fb64 100644
> --- a/drivers/video/fbdev/matrox/matroxfb_base.c
> +++ b/drivers/video/fbdev/matrox/matroxfb_base.c
> @@ -374,10 +374,6 @@ static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy)
> unregister_framebuffer(&minfo->fbcon);
> matroxfb_g450_shutdown(minfo);
> arch_phys_wc_del(minfo->wc_cookie);
> - iounmap(minfo->mmio.vbase.vaddr);
> - iounmap(minfo->video.vbase.vaddr);
> - release_mem_region(minfo->video.base, minfo->video.len_maximum);
> - release_mem_region(minfo->mmio.base, 16384);
> kfree(minfo);
> }
[Severity: High]
Will this cause a crash if the device is removed while still in use?
Looking earlier in matroxfb_remove(), there is an early return that defers
cleanup if the device is busy:
static void matroxfb_remove(struct matrox_fb_info *minfo, int dummy)
{
...
minfo->dead = 1;
if (minfo->usecount) {
/* destroy it later */
return;
}
...
}
By converting the allocations to the devm_ and pcim_ APIs, the resources
like the MMIO mappings and the PCI enable state will be automatically freed
as soon as matroxfb_remove() returns to the driver core.
If minfo->usecount is non-zero, won't this unmap and disable the device
while userspace or other subsystems are still actively interacting with the
framebuffer, leading to a memory fault?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260813125015.1097301-1-oushixiong1025@163.com?part=4
next prev parent reply other threads:[~2026-08-13 13:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 12:50 [PATCH 1/5] fbdev: aty128fb: Convert to managed PCI and ioremap API oushixiong1025
2026-08-13 12:50 ` [PATCH 2/5] fbdev: nvidia: " oushixiong1025
2026-08-13 12:50 ` [PATCH 3/5] fbdev: savage: " oushixiong1025
2026-08-13 12:50 ` [PATCH 4/5] fbdev: matrox: " oushixiong1025
2026-08-13 13:02 ` sashiko-bot [this message]
2026-08-13 12:50 ` [PATCH 5/5] fbdev: atyfb: " oushixiong1025
2026-08-13 13:13 ` sashiko-bot
2026-08-13 12:57 ` [PATCH 1/5] fbdev: aty128fb: " sashiko-bot
2026-08-13 15:45 ` Helge Deller
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=20260813130207.C1F8E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=oushixiong1025@163.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.