From patchwork Mon Jan 19 18:38:08 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: 5660421 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 33A1D9F333 for ; Mon, 19 Jan 2015 18:38:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 61CCF20435 for ; Mon, 19 Jan 2015 18:38:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEDD120412 for ; Mon, 19 Jan 2015 18:38:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751983AbbASSie (ORCPT ); Mon, 19 Jan 2015 13:38:34 -0500 Received: from mout.web.de ([212.227.17.11]:55791 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752419AbbASSiR (ORCPT ); Mon, 19 Jan 2015 13:38:17 -0500 Received: from [192.168.1.2] ([78.48.242.248]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M3T5g-1XvkOc2lbU-00qvym; Mon, 19 Jan 2015 19:38:14 +0100 Message-ID: <54BD4F10.9040401@users.sourceforge.net> Date: Mon, 19 Jan 2015 19:38:08 +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: [PATCH 5/9] video: Less function calls in trident_pci_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:fKoxAnPOtwDvSdY4ocfboj15fRVq2ISBw8y3tNHWF/ctk23aOEz wSDEVaARhvy32bX+8nyLA0u1I98FQU52qmQTaJkhRMV2iN07bDOKY0EH7hvCodhQIW2oXD3 YqO0Qd1rpdW5rm62gpKPabhMtPcuxS61eQR4wclMpZ1B+cAgDLFpedfN/VCfkKwEQ5ezNRP bzJxqcmapv4v/5BApxrhg== 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=unavailable 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: Mon, 19 Jan 2015 14:18:47 +0100 The functions "iounmap" and "kfree" could be called in a few cases by the trident_pci_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/tridentfb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/tridentfb.c b/drivers/video/fbdev/tridentfb.c index 71567401..86d4733 100644 --- a/drivers/video/fbdev/tridentfb.c +++ b/drivers/video/fbdev/tridentfb.c @@ -1436,7 +1436,7 @@ static int trident_pci_probe(struct pci_dev *dev, if (!default_par->io_virt) { debug("ioremap failed\n"); err = -1; - goto out_unmap1; + goto release_memory_region_mmio; } enable_mmio(default_par); @@ -1459,7 +1459,7 @@ static int trident_pci_probe(struct pci_dev *dev, if (!info->screen_base) { debug("ioremap failed\n"); err = -1; - goto out_unmap2; + goto release_memory_region_smem; } default_par->flatpanel = is_flatpanel(default_par); @@ -1485,7 +1485,7 @@ static int trident_pci_probe(struct pci_dev *dev, info->pixmap.addr = kmalloc(4096, GFP_KERNEL); if (!info->pixmap.addr) { err = -ENOMEM; - goto out_unmap2; + goto io_unmap_screenbase; } info->pixmap.size = 4096; @@ -1531,11 +1531,14 @@ static int trident_pci_probe(struct pci_dev *dev, out_unmap2: kfree(info->pixmap.addr); +io_unmap_screenbase: iounmap(info->screen_base); +release_memory_region_smem: release_mem_region(tridentfb_fix.smem_start, tridentfb_fix.smem_len); disable_mmio(info->par); out_unmap1: iounmap(default_par->io_virt); +release_memory_region_mmio: release_mem_region(tridentfb_fix.mmio_start, tridentfb_fix.mmio_len); framebuffer_release(info); return err;