* [PATCH] video: hpfb: Unregister DIO driver on init failure
@ 2026-06-22 6:49 Haoxiang Li
2026-06-23 8:10 ` Helge Deller
2026-06-24 8:51 ` Geert Uytterhoeven
0 siblings, 2 replies; 4+ messages in thread
From: Haoxiang Li @ 2026-06-22 6:49 UTC (permalink / raw)
To: deller; +Cc: linux-fbdev, dri-devel, linux-kernel, Haoxiang Li
hpfb_init() registers the DIO driver via dio_register_driver().
If a later error occurs, the function returns directly without
unregistering the DIO driver. Unregister the DIO driver before
returning from these error paths.
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
---
drivers/video/fbdev/hpfb.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/hpfb.c b/drivers/video/fbdev/hpfb.c
index a1144b150982..1405712e5b4f 100644
--- a/drivers/video/fbdev/hpfb.c
+++ b/drivers/video/fbdev/hpfb.c
@@ -407,10 +407,13 @@ static int __init hpfb_init(void)
err = copy_from_kernel_nofault(&i, (unsigned char *)INTFBVADDR + DIO_IDOFF, 1);
if (!err && (i == DIO_ID_FBUFFER) && topcat_sid_ok(sid = DIO_SECID(INTFBVADDR))) {
- if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat"))
+ if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat")) {
+ dio_unregister_driver(&hpfb_driver);
return -EBUSY;
+ }
printk(KERN_INFO "Internal Topcat found (secondary id %02x)\n", sid);
if (hpfb_init_one(INTFBPADDR, INTFBVADDR)) {
+ dio_unregister_driver(&hpfb_driver);
return -ENOMEM;
}
}
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] video: hpfb: Unregister DIO driver on init failure
2026-06-22 6:49 [PATCH] video: hpfb: Unregister DIO driver on init failure Haoxiang Li
@ 2026-06-23 8:10 ` Helge Deller
2026-06-24 8:51 ` Geert Uytterhoeven
1 sibling, 0 replies; 4+ messages in thread
From: Helge Deller @ 2026-06-23 8:10 UTC (permalink / raw)
To: Haoxiang Li; +Cc: linux-fbdev, dri-devel, linux-kernel
On 6/22/26 08:49, Haoxiang Li wrote:
> hpfb_init() registers the DIO driver via dio_register_driver().
> If a later error occurs, the function returns directly without
> unregistering the DIO driver. Unregister the DIO driver before
> returning from these error paths.
>
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
> ---
> drivers/video/fbdev/hpfb.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
Thanks! Patch applied to fbdev git tree.
By the way... doesn't the request_mem_region() below needs a corresponding
release_mem_region() in the failure path?
Helge
>
> diff --git a/drivers/video/fbdev/hpfb.c b/drivers/video/fbdev/hpfb.c
> index a1144b150982..1405712e5b4f 100644
> --- a/drivers/video/fbdev/hpfb.c
> +++ b/drivers/video/fbdev/hpfb.c
> @@ -407,10 +407,13 @@ static int __init hpfb_init(void)
> err = copy_from_kernel_nofault(&i, (unsigned char *)INTFBVADDR + DIO_IDOFF, 1);
>
> if (!err && (i == DIO_ID_FBUFFER) && topcat_sid_ok(sid = DIO_SECID(INTFBVADDR))) {
> - if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat"))
> + if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat")) {
> + dio_unregister_driver(&hpfb_driver);
> return -EBUSY;
> + }
> printk(KERN_INFO "Internal Topcat found (secondary id %02x)\n", sid);
> if (hpfb_init_one(INTFBPADDR, INTFBVADDR)) {
> + dio_unregister_driver(&hpfb_driver);
> return -ENOMEM;
> }
> }
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] video: hpfb: Unregister DIO driver on init failure
2026-06-22 6:49 [PATCH] video: hpfb: Unregister DIO driver on init failure Haoxiang Li
2026-06-23 8:10 ` Helge Deller
@ 2026-06-24 8:51 ` Geert Uytterhoeven
2026-06-24 9:18 ` haoxiang_li2024
1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2026-06-24 8:51 UTC (permalink / raw)
To: Haoxiang Li
Cc: deller, linux-fbdev, dri-devel, linux-kernel, Philip Blundell,
Kars de Jong, linux-m68k
Hi Haoxiang,
CC hp300
On Tue, 23 Jun 2026 at 06:41, Haoxiang Li <haoxiang_li2024@163.com> wrote:
> hpfb_init() registers the DIO driver via dio_register_driver().
> If a later error occurs, the function returns directly without
> unregistering the DIO driver. Unregister the DIO driver before
> returning from these error paths.
>
> Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Thanks for your patch, which is now commit d6c3e2402523ce01 ("fbdev:
hpfb: Unregister DIO driver on init failure") in fbdev/for-next
> --- a/drivers/video/fbdev/hpfb.c
> +++ b/drivers/video/fbdev/hpfb.c
> @@ -407,10 +407,13 @@ static int __init hpfb_init(void)
As per the comment out-of-context above, this driver supports devices
on two types of buses:
/* Topcats can be on the internal IO bus or real DIO devices.
* The internal variant sits at 0x560000; it has primary
* and secondary ID registers just like the DIO version.
* So we merge the two detection routines.
> err = copy_from_kernel_nofault(&i, (unsigned char *)INTFBVADDR + DIO_IDOFF, 1);
>
> if (!err && (i == DIO_ID_FBUFFER) && topcat_sid_ok(sid = DIO_SECID(INTFBVADDR))) {
> - if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat"))
> + if (!request_mem_region(INTFBPADDR, DIO_DEVSIZE, "Internal Topcat")) {
> + dio_unregister_driver(&hpfb_driver);
> return -EBUSY;
> + }
> printk(KERN_INFO "Internal Topcat found (secondary id %02x)\n", sid);
> if (hpfb_init_one(INTFBPADDR, INTFBVADDR)) {
> + dio_unregister_driver(&hpfb_driver);
> return -ENOMEM;
> }
> }
Hence if the detection or initialization on the internal bus fails,
other devices on the DIO bus must not be force-unbound.
This is also the reason why any error returned by
copy_from_kernel_nofault() is not considered fatal.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re:Re: [PATCH] video: hpfb: Unregister DIO driver on init failure
2026-06-24 8:51 ` Geert Uytterhoeven
@ 2026-06-24 9:18 ` haoxiang_li2024
0 siblings, 0 replies; 4+ messages in thread
From: haoxiang_li2024 @ 2026-06-24 9:18 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: deller, linux-fbdev, dri-devel, linux-kernel, Philip Blundell,
Kars de Jong, linux-m68k
At 2026-06-24 16:51:02, "Geert Uytterhoeven" <geert@linux-m68k.org> wrote:
>Hence if the detection or initialization on the internal bus fails,
>other devices on the DIO bus must not be force-unbound.
>
>This is also the reason why any error returned by
>copy_from_kernel_nofault() is not considered fatal.
>
Thanks for your guidance! Understand that now.
Thanks,
Haoxiang
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-24 9:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-22 6:49 [PATCH] video: hpfb: Unregister DIO driver on init failure Haoxiang Li
2026-06-23 8:10 ` Helge Deller
2026-06-24 8:51 ` Geert Uytterhoeven
2026-06-24 9:18 ` haoxiang_li2024
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox