From patchwork Thu Nov 20 23:54:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 5351401 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 3C3A7C11AC for ; Thu, 20 Nov 2014 23:54:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3EFBC20225 for ; Thu, 20 Nov 2014 23:54:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 44DBE20220 for ; Thu, 20 Nov 2014 23:54:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 12DD56E982; Thu, 20 Nov 2014 15:54:31 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qg0-f41.google.com (mail-qg0-f41.google.com [209.85.192.41]) by gabe.freedesktop.org (Postfix) with ESMTP id 593A46E982 for ; Thu, 20 Nov 2014 15:54:30 -0800 (PST) Received: by mail-qg0-f41.google.com with SMTP id j5so2978995qga.14 for ; Thu, 20 Nov 2014 15:54:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=CQaf6+c7Ib8FpVyYRHMOWS4ekBmqrd0Jz/SSu3K3X30=; b=nJfyvzdmSPOplD9rUhCYWJ8ezWrjW5WUItNxapkp1Wrp9VR+0IzAy5zJ0BwxrlnUhV gyzmI+tXB1VFToGe1DE17HbIElF9/mORXy+q/nEhXI0xZQC0/XbZaUw7ZxgeoB8d5RSS 0bzmZWkAdd1Xd17uMhqQMuojVlAKNBZ7D8GMaiqt5vaEKKMIWKn/cHsLj8Q5ylhYnB+I 0VDBsRX0ZYQN7pgDqpQuUsyNcbCieOapdHE6VmAkp9roLPq++/gnA6OiOuvlbhmz4XOw DveyG/ZnZ3fsSoUxuiJc8MSnA044XCdfV9cxpmREk5N2V5XY8XA8Itb+1HkCdJ/yKkRE MHPQ== X-Received: by 10.140.96.101 with SMTP id j92mr1540023qge.87.1416527669764; Thu, 20 Nov 2014 15:54:29 -0800 (PST) Received: from localhost.localdomain ([187.34.44.229]) by mx.google.com with ESMTPSA id d2sm3294075qab.24.2014.11.20.15.54.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Nov 2014 15:54:28 -0800 (PST) From: Gustavo Padovan To: linux-samsung-soc@vger.kernel.org Subject: [PATCH 1/3] drm/exynos: free DP if probe fails to find a panel or bridge Date: Thu, 20 Nov 2014 21:54:22 -0200 Message-Id: <1416527664-10553-1-git-send-email-gustavo@padovan.org> X-Mailer: git-send-email 1.9.3 Cc: Gustavo Padovan , dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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: Gustavo Padovan DP was leaked everytime function returns EPROBE_DEFER, free it before returning. Signed-off-by: Gustavo Padovan --- drivers/gpu/drm/exynos/exynos_dp_core.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_dp_core.c b/drivers/gpu/drm/exynos/exynos_dp_core.c index 85762cf..6fd4a46 100644 --- a/drivers/gpu/drm/exynos/exynos_dp_core.c +++ b/drivers/gpu/drm/exynos/exynos_dp_core.c @@ -1336,8 +1336,10 @@ static int exynos_dp_probe(struct platform_device *pdev) if (panel_node) { dp->panel = of_drm_find_panel(panel_node); of_node_put(panel_node); - if (!dp->panel) - return -EPROBE_DEFER; + if (!dp->panel) { + ret = -EPROBE_DEFER; + goto free_dp; + } } endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); @@ -1346,10 +1348,14 @@ static int exynos_dp_probe(struct platform_device *pdev) if (bridge_node) { dp->bridge = of_drm_find_bridge(bridge_node); of_node_put(bridge_node); - if (!dp->bridge) - return -EPROBE_DEFER; - } else - return -EPROBE_DEFER; + if (!dp->bridge) { + ret = -EPROBE_DEFER; + goto free_dp; + } + } else { + ret = -EPROBE_DEFER; + goto free_dp; + } } exynos_dp_display.ctx = dp; @@ -1359,6 +1365,9 @@ static int exynos_dp_probe(struct platform_device *pdev) exynos_drm_component_del(&pdev->dev, EXYNOS_DEVICE_TYPE_CONNECTOR); +free_dp: + devm_kfree(dev, dp); + return ret; }