Re: [PATCH 1/4] fbdev: imsttfb: Fix error handling in init_imstt()

Started by Helge Deller on May 25, 2023

open the first message on its own page

Message details and related content
On 5/25/23 07:33, Markus Elfring wrote:
quoted
quoted
The return value was overlooked from a call of
the function “fb_alloc_cmap”.

* Thus use a corresponding error check.

* Add two jump targets so that a bit of exception handling
    can be better reused at the end of this function.
…
quoted
quoted
+++ b/drivers/video/fbdev/imsttfb.c
…
quoted
quoted
@@ -1452,17 +1452,25 @@ static int init_imstt(struct fb_info *info)
                     FBINFO_HWACCEL_FILLRECT |
                     FBINFO_HWACCEL_YPAN;

-    fb_alloc_cmap(&info->cmap, 0, 0);
+    ret = fb_alloc_cmap(&info->cmap, 0, 0);
+    if (ret)
+        goto release_framebuffer;

       if (register_framebuffer(info) < 0) {
-        framebuffer_release(info);
-        return -ENODEV;
+        fb_dealloc_cmap(&info->cmap);
+        goto e_nodev;
       }

       tmp = (read_reg_le32(par->dc_regs, SSTATUS) & 0x0f00) >> 8;
       fb_info(info, "%s frame buffer; %uMB vram; chip version %u\n",
           info->fix.id, info->fix.smem_len >> 20, tmp);
       return 0;
+
+e_nodev:
+    ret = -ENODEV;
I think the return value isn't checked at all, so you could
simply return below "-ENODEV" for all cases (instead of "return ret").
Then you don't need the e_nodev label and can simplify the flow.
Can it be helpful to distinguish involved error codes better?
No.

Helge
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help