From patchwork Sun Jul 28 00:08:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 2834819 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BBC6AC0319 for ; Mon, 29 Jul 2013 06:39:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BE57201C0 for ; Mon, 29 Jul 2013 06:39:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2654120163 for ; Mon, 29 Jul 2013 06:39:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CFD1BE5EF9 for ; Sun, 28 Jul 2013 23:39:47 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) by gabe.freedesktop.org (Postfix) with ESMTP id C17F2E7600 for ; Sat, 27 Jul 2013 17:08:19 -0700 (PDT) Received: by mail-bk0-f53.google.com with SMTP id e11so1538617bkh.40 for ; Sat, 27 Jul 2013 17:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=0gMJyvcoCXAIyZX2PZTf1vO8oUmj1dyc7qzvlvlrHpc=; b=RUkYbC3cYGkIb99q0M7PVsWGJ7AVTetH5Ds0QKRBVPOQn9020z/MKjOCBtM5lQyw6+ iNwkBkvUwdki22WPiPFKncW+VPFaZ2hn1c+ALuIP9GrSN4GilqITs5A5xnnzaiUCzrEr 3Mt2Pv710I+jf2m8H1/1r7otYJcBxlemujc63uOcPTlLIgIYVybqo3h3OGyvITtJqpvl d+rWUWZEcBhCQbHnR7Llo/0WbjlFEIXOMkpsZj6LQHV+wgjUgaRZ8UB7lkrfGB3/AwVG zwXxwqFGOEVxojpZuzFVkZ1sSxHs2wVL6YV+9/nOkyAjI6xn1ZEUFNrvOSQIbfgUdp/J gNDQ== MIME-Version: 1.0 X-Received: by 10.204.224.77 with SMTP id in13mr7901772bkb.24.1374970098582; Sat, 27 Jul 2013 17:08:18 -0700 (PDT) Received: by 10.205.122.72 with HTTP; Sat, 27 Jul 2013 17:08:18 -0700 (PDT) Date: Sun, 28 Jul 2013 08:08:18 +0800 Message-ID: Subject: [PATCH] drm/cirrus: fix error handling in cirrus_device_init() From: Wei Yongjun To: airlied@linux.ie, daniel.vetter@ffwll.ch, airlied@gmail.com, paulmck@linux.vnet.ibm.com, dhowells@redhat.com, davej@redhat.com X-Mailman-Approved-At: Sun, 28 Jul 2013 22:49:26 -0700 Cc: yongjun_wei@trendmicro.com.cn, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Wei Yongjun Fix the error handling in function cirrus_device_init() to avoid resources leak in the error handling case. Signed-off-by: Wei Yongjun --- drivers/gpu/drm/cirrus/cirrus_main.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c index 3a7a0ef..5f59bb0 100644 --- a/drivers/gpu/drm/cirrus/cirrus_main.c +++ b/drivers/gpu/drm/cirrus/cirrus_main.c @@ -138,17 +138,22 @@ int cirrus_device_init(struct cirrus_device *cdev, } cdev->rmmio = ioremap(cdev->rmmio_base, cdev->rmmio_size); - - if (cdev->rmmio == NULL) - return -ENOMEM; + if (cdev->rmmio == NULL) { + ret = -ENOMEM; + goto err_ioremap; + } ret = cirrus_vram_init(cdev); - if (ret) { - release_mem_region(cdev->rmmio_base, cdev->rmmio_size); - return ret; - } + if (ret) + goto err_init; return 0; + +err_init: + iounmap(cdev->rmmio); +err_ioremap: + release_mem_region(cdev->rmmio_base, cdev->rmmio_size); + return ret; } void cirrus_device_fini(struct cirrus_device *cdev)