Re: [PATCH] video: hpfb: Unregister DIO driver on init failure

Geert Uytterhoeven <[email protected]>
Newsgroups org.kernel.vger.linux-m68k,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-fbdev,org.kernel.vger.linux-kernel
Message-ID <CAMuHMdUSVacMR2Lb-VwkeZMrS=wKz9y+XtF=nAOCuSLbDs-HdQ@mail.gmail.com>
Hi Haoxiang,

CC hp300

On Tue, 23 Jun 2026 at 06:41, Haoxiang Li <[email protected]> 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 <[email protected]>

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 -- [email protected]

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.