[PATCH] fbdev: arkfb: Request legacy VGA I/O region

Swaraj Gaikwad posted 1 patch 9 hours ago
There is a newer version of this series
drivers/video/fbdev/arkfb.c | 6 ++++++
1 file changed, 6 insertions(+)
[PATCH] fbdev: arkfb: Request legacy VGA I/O region
Posted by Swaraj Gaikwad 9 hours ago
The arkfb driver uses the legacy VGA I/O range (0x3c0+) but does not
request it. This can cause conflicts with other drivers that try to
reserve these ports.

Fix this by using devm_request_region() during the probe function.
This ensures the region is properly reserved and automatically released
on driver detach.

Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>
---
Compile-tested only on x86_64.

 drivers/video/fbdev/arkfb.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
index ec084323115f..24e4c20d1a32 100644
--- a/drivers/video/fbdev/arkfb.c
+++ b/drivers/video/fbdev/arkfb.c
@@ -1018,6 +1018,12 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)

 	pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);

+	if (!devm_request_region(&dev->dev, vga_res.start, 64 * 1024, "arkfb-vga")) {
+		dev_err(info->device, "cannot reserve legacy VGA ports\n");
+		rc = -EBUSY;
+		goto err_find_mode;
+	}
+
 	par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;

 	/* FIXME get memsize */

base-commit: a859eca0e4cc96f63ff125dbe5388d961558b0e9
--
2.52.0
Re: [PATCH] fbdev: arkfb: Request legacy VGA I/O region
Posted by Kees Cook 11 hours ago
On Sat, Dec 13, 2025 at 03:49:32PM +0000, Swaraj Gaikwad wrote:
> The arkfb driver uses the legacy VGA I/O range (0x3c0+) but does not
> request it. This can cause conflicts with other drivers that try to
> reserve these ports.

Eek, nice catch!

> 
> Fix this by using devm_request_region() during the probe function.
> This ensures the region is properly reserved and automatically released
> on driver detach.
> 
> Signed-off-by: Swaraj Gaikwad <swarajgaikwad1925@gmail.com>
> ---
> Compile-tested only on x86_64.
> 
>  drivers/video/fbdev/arkfb.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/video/fbdev/arkfb.c b/drivers/video/fbdev/arkfb.c
> index ec084323115f..24e4c20d1a32 100644
> --- a/drivers/video/fbdev/arkfb.c
> +++ b/drivers/video/fbdev/arkfb.c
> @@ -1018,6 +1018,12 @@ static int ark_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
> 
>  	pcibios_bus_to_resource(dev->bus, &vga_res, &bus_reg);
> 
> +	if (!devm_request_region(&dev->dev, vga_res.start, 64 * 1024, "arkfb-vga")) {

I was expecting to see vga_res.end as the third argument instead of
repeating the open-coded value.

-Kees

> +		dev_err(info->device, "cannot reserve legacy VGA ports\n");
> +		rc = -EBUSY;
> +		goto err_find_mode;
> +	}
> +
>  	par->state.vgabase = (void __iomem *) (unsigned long) vga_res.start;
> 
>  	/* FIXME get memsize */
> 
> base-commit: a859eca0e4cc96f63ff125dbe5388d961558b0e9
> --
> 2.52.0
> 

-- 
Kees Cook