lkml.org 
[lkml]   [2015]   [Jan]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH 9/9] video: Less function calls in w100fb_probe() after error detection
    From: Markus Elfring <elfring@users.sourceforge.net>
    Date: Mon, 19 Jan 2015 17:56:11 +0100

    The iounmap() function could be called in three cases by the w100fb_probe()
    function during error handling even if the passed data structure element
    contained still a null pointer.

    * This implementation detail could be improved by adjustments for
    jump labels.

    * Let us also delete two unnecessary null pointer checks for the
    variable "info".

    Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
    ---
    drivers/video/fbdev/w100fb.c | 31 +++++++++++++++++--------------
    1 file changed, 17 insertions(+), 14 deletions(-)

    diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
    index aeb53eb..67ddc57 100644
    --- a/drivers/video/fbdev/w100fb.c
    +++ b/drivers/video/fbdev/w100fb.c
    @@ -645,12 +645,12 @@ int w100fb_probe(struct platform_device *pdev)
    /* Remap the chip base address */
    remapped_base = ioremap_nocache(mem->start+W100_CFG_BASE, W100_CFG_LEN);
    if (remapped_base == NULL)
    - goto out;
    + goto exit;

    /* Map the register space */
    remapped_regs = ioremap_nocache(mem->start+W100_REG_BASE, W100_REG_LEN);
    if (remapped_regs == NULL)
    - goto out;
    + goto io_unmap_base;

    /* Identify the chip */
    printk("Found ");
    @@ -662,19 +662,19 @@ int w100fb_probe(struct platform_device *pdev)
    default:
    printk("Unknown imageon chip ID\n");
    err = -ENODEV;
    - goto out;
    + goto io_unmap_regs;
    }
    printk(" at 0x%08lx.\n", (unsigned long) mem->start+W100_CFG_BASE);

    /* Remap the framebuffer */
    remapped_fbuf = ioremap_nocache(mem->start+MEM_WINDOW_BASE, MEM_WINDOW_SIZE);
    if (remapped_fbuf == NULL)
    - goto out;
    + goto io_unmap_regs;

    info=framebuffer_alloc(sizeof(struct w100fb_par), &pdev->dev);
    if (!info) {
    err = -ENOMEM;
    - goto out;
    + goto io_unmap_framebuffer;
    }

    par = info->par;
    @@ -690,13 +690,13 @@ int w100fb_probe(struct platform_device *pdev)
    if (!par->pll_table) {
    printk(KERN_ERR "No matching Xtal definition found\n");
    err = -EINVAL;
    - goto out;
    + goto release_framebuffer;
    }

    info->pseudo_palette = kmalloc(sizeof (u32) * MAX_PALETTES, GFP_KERNEL);
    if (!info->pseudo_palette) {
    err = -ENOMEM;
    - goto out;
    + goto release_framebuffer;
    }

    info->fbops = &w100fb_ops;
    @@ -716,7 +716,7 @@ int w100fb_probe(struct platform_device *pdev)

    if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
    err = -ENOMEM;
    - goto out;
    + goto free_palette;
    }

    par->mode = &inf->modelist[0];
    @@ -766,15 +766,18 @@ int w100fb_probe(struct platform_device *pdev)
    fb_info(info, "%s frame buffer device\n", info->fix.id);
    return 0;
    out:
    - if (info) {
    - fb_dealloc_cmap(&info->cmap);
    - kfree(info->pseudo_palette);
    - }
    + fb_dealloc_cmap(&info->cmap);
    +free_palette:
    + kfree(info->pseudo_palette);
    +release_framebuffer:
    + framebuffer_release(info);
    +io_unmap_framebuffer:
    iounmap(remapped_fbuf);
    +io_unmap_regs:
    iounmap(remapped_regs);
    +io_unmap_base:
    iounmap(remapped_base);
    - if (info)
    - framebuffer_release(info);
    +exit:
    return err;
    }

    --
    2.2.2


    \
     
     \ /
      Last update: 2015-01-19 20:01    [W:2.276 / U:1.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site