From patchwork Mon Jan 19 18:25:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 5660341 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 31CBAC058D for ; Mon, 19 Jan 2015 18:25:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38F0E20364 for ; Mon, 19 Jan 2015 18:25:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CBE52041C for ; Mon, 19 Jan 2015 18:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752323AbbASSZj (ORCPT ); Mon, 19 Jan 2015 13:25:39 -0500 Received: from mout.web.de ([212.227.17.11]:64015 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751996AbbASSZi (ORCPT ); Mon, 19 Jan 2015 13:25:38 -0500 Received: from [192.168.1.2] ([78.48.242.248]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0M9XQB-1Y1TS13olT-00D24G; Mon, 19 Jan 2015 19:25:31 +0100 Message-ID: <54BD4C19.6040500@users.sourceforge.net> Date: Mon, 19 Jan 2015 19:25:29 +0100 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: video: One function call less in tdfxfb_probe() after error detection References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <54BD44F0.3040705@users.sourceforge.net> In-Reply-To: <54BD44F0.3040705@users.sourceforge.net> X-Provags-ID: V03:K0:a6WDEXxnx7Jm9IuuO/6USfvCwf87nvHIk0IGH8/nVKjcbuEqDlm GL0ZN7D2VjmAUQ9ZrqcUMmorUQ56E0r1dqjMNsNfZDhiYiCnjj5QvlsGHublbtNbEhYQcR4 Qpgbw9miYDVNz4xwT7j9gcICSgvMU3z3CztF+1MoBLLs7kuSzFBJkbfP6CkfUOcewRoXZld 3JTq65xEOnJhRl42oj/Iw== X-UI-Out-Filterresults: notjunk:1; Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 18 Jan 2015 23:30:41 +0100 The iounmap() function could be called in two cases by the tdfxfb_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. Signed-off-by: Markus Elfring --- drivers/video/fbdev/tdfxfb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/video/fbdev/tdfxfb.c b/drivers/video/fbdev/tdfxfb.c index 69d4062..c280a3b 100644 --- a/drivers/video/fbdev/tdfxfb.c +++ b/drivers/video/fbdev/tdfxfb.c @@ -1438,20 +1438,20 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (!default_par->regbase_virt) { printk(KERN_ERR "fb: Can't remap %s register area.\n", info->fix.id); - goto out_err_regbase; + goto release_memory_region_regbase; } info->fix.smem_start = pci_resource_start(pdev, 1); info->fix.smem_len = do_lfb_size(default_par, pdev->device); if (!info->fix.smem_len) { printk(KERN_ERR "fb: Can't count %s memory.\n", info->fix.id); - goto out_err_regbase; + goto io_unmap_regbase; } if (!request_mem_region(info->fix.smem_start, pci_resource_len(pdev, 1), "tdfx smem")) { printk(KERN_ERR "tdfxfb: Can't reserve smem\n"); - goto out_err_regbase; + goto io_unmap_regbase; } info->screen_base = ioremap_nocache(info->fix.smem_start, @@ -1459,7 +1459,7 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (!info->screen_base) { printk(KERN_ERR "fb: Can't remap %s framebuffer.\n", info->fix.id); - goto out_err_screenbase; + goto release_memory_region_screenbase; } default_par->iobase = pci_resource_start(pdev, 2); @@ -1467,7 +1467,7 @@ static int tdfxfb_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (!request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2), "tdfx iobase")) { printk(KERN_ERR "tdfxfb: Can't reserve iobase\n"); - goto out_err_screenbase; + goto io_unmap_screenbase; } printk(KERN_INFO "fb: %s memory = %dK\n", info->fix.id, @@ -1571,14 +1571,16 @@ out_err_iobase: info->fix.smem_len); release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); -out_err_screenbase: +io_unmap_screenbase: iounmap(info->screen_base); +release_memory_region_screenbase: release_mem_region(info->fix.smem_start, pci_resource_len(pdev, 1)); -out_err_regbase: +io_unmap_regbase: /* * Cleanup after anything that was remapped/allocated. */ iounmap(default_par->regbase_virt); +release_memory_region_regbase: release_mem_region(info->fix.mmio_start, info->fix.mmio_len); out_err: framebuffer_release(info);