From patchwork Mon Jul 4 14:11:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 942252 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p64Ef62j021630 for ; Mon, 4 Jul 2011 14:41:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755802Ab1GDOMP (ORCPT ); Mon, 4 Jul 2011 10:12:15 -0400 Received: from mgw2.diku.dk ([130.225.96.92]:35348 "EHLO mgw2.diku.dk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753600Ab1GDOLv (ORCPT ); Mon, 4 Jul 2011 10:11:51 -0400 Received: from localhost (localhost [127.0.0.1]) by mgw2.diku.dk (Postfix) with ESMTP id CEDFB19BBF8; Mon, 4 Jul 2011 16:11:50 +0200 (CEST) Received: from mgw2.diku.dk ([127.0.0.1]) by localhost (mgw2.diku.dk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32502-12; Mon, 4 Jul 2011 16:11:47 +0200 (CEST) Received: from palace.topps.diku.dk (palace.ekstranet.diku.dk [192.38.115.202]) by mgw2.diku.dk (Postfix) with ESMTP id 92A4519BC09; Mon, 4 Jul 2011 16:11:45 +0200 (CEST) From: Julia Lawall To: David Brown Cc: kernel-janitors@vger.kernel.org, Daniel Walker , Bryan Huntsman , Paul Mundt , linux-arm-msm@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] drivers/video/msm/mdp.c: adjust error handling code Date: Mon, 4 Jul 2011 16:11:45 +0200 Message-Id: <1309788705-22278-5-git-send-email-julia@diku.dk> X-Mailer: git-send-email 1.7.1 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 04 Jul 2011 14:41:07 +0000 (UTC) From: Julia Lawall Use the error handling code at the end of the function, rather than returning directly. The semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // @r@ identifier x; @@ kfree(x) @@ identifier r.x; expression E1!=0,E2,E3,E4; statement S; @@ ( if (<+...x...+>) S | if (...) { ... when != kfree(x) when != if (...) { ... kfree(x); ... } when != x = E3 * return E1; } ... when != x = E2 if (...) { ... when != x = E4 kfree(x); ... return ...; } ) // Signed-off-by: Julia Lawall --- I wonder if the error handling code at the end of the function should be calling clk_put as well? In that case, having a separate label for this case would be useful. Otherwise, one of error_request_irq and error_get_clk can be deleted drivers/video/msm/mdp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/video/msm/mdp.c b/drivers/video/msm/mdp.c index 243d16f..01fa660 100644 --- a/drivers/video/msm/mdp.c +++ b/drivers/video/msm/mdp.c @@ -421,7 +421,8 @@ int mdp_probe(struct platform_device *pdev) clk = clk_get(&pdev->dev, "mdp_clk"); if (IS_ERR(clk)) { printk(KERN_INFO "mdp: failed to get mdp clk"); - return PTR_ERR(clk); + ret = PTR_ERR(clk); + goto error_get_clk; } ret = request_irq(mdp->irq, mdp_isr, IRQF_DISABLED, "msm_mdp", mdp); @@ -495,6 +496,7 @@ int mdp_probe(struct platform_device *pdev) error_device_register: free_irq(mdp->irq, mdp); error_request_irq: +error_get_clk: iounmap(mdp->base); error_get_irq: error_ioremap: