From patchwork Wed Jun 8 11:33:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 69631 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2440202qgf; Wed, 8 Jun 2016 04:34:06 -0700 (PDT) X-Received: by 10.98.76.23 with SMTP id z23mr4852513pfa.85.1465385646373; Wed, 08 Jun 2016 04:34:06 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a7si1057512paw.7.2016.06.08.04.34.00; Wed, 08 Jun 2016 04:34:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752978AbcFHLeA (ORCPT + 4 others); Wed, 8 Jun 2016 07:34:00 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:19553 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751551AbcFHLd7 (ORCPT ); Wed, 8 Jun 2016 07:33:59 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O8G00FH2ASJK900@mailout1.w1.samsung.com>; Wed, 08 Jun 2016 12:33:55 +0100 (BST) X-AuditID: cbfec7f4-f796c6d000001486-b6-575802a374bf Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id A4.D6.05254.3A208575; Wed, 8 Jun 2016 12:33:55 +0100 (BST) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O8G00J34ASFQHB0@eusync2.samsung.com>; Wed, 08 Jun 2016 12:33:55 +0100 (BST) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Kamil Debski , Kukjin Kim , Krzysztof Kozlowski , Javier Martinez Canillas , Bartlomiej Zolnierkiewicz , Liviu Dudau Subject: [PATCH] media: s5p-mfc: fix error path in driver probe Date: Wed, 08 Jun 2016 13:33:40 +0200 Message-id: <1465385620-4396-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <20160608103629.GD21784@bart.dudau.co.uk> References: <20160608103629.GD21784@bart.dudau.co.uk> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrELMWRmVeSWpSXmKPExsVy+t/xK7qLmSLCDSbP0rfYOGM9q8Wbt2uY LH68vsBm8fqFoUX/49fMFj0btrJazDi/j8ni7+LDLBZrj9xltzj8pp3Vgcvjx/6vrB6bVnWy eWzpv8vu0bdlFaPH501yAaxRXDYpqTmZZalF+nYJXBlfd+xhKtguULG3bxp7A+M53i5GTg4J AROJdac/s0DYYhIX7q1n62Lk4hASWMoo8fNJEyOE08QkMaPpDhtIFZuAoUTX2y4wW0TASWLh rL/sIEXMAk+ZJB4/mMEKkhAWsJd4tO01O4jNIqAqcffqXEYQm1fAXWL+xR9sEOvkJP6/XMHU xcjBwSlgJvHyvRpIWEjAVKLv/EX2CYy8CxgZVjGKppYmFxQnpeca6hUn5haX5qXrJefnbmKE hNyXHYyLj1kdYhTgYFTi4VUwDA8XYk0sK67MPcQowcGsJMJ78z9QiDclsbIqtSg/vqg0J7X4 EKM0B4uSOO/cXe9DhATSE0tSs1NTC1KLYLJMHJxSDYw+mz/PzeDl9hI9/MNa8VjwrI+RRY+k Hs4w/7i47Nnpb218ZidmbTvY95cjZ8Kp6Av/cm6pntD7N/UjI1tr/IJFa4vT8iTlQ3demfGX XTuyvWePmOJsA+XZJU08Lw7LrZ7CO9NO47er0YxbkbrP9Q4o5LdsYV95eMbacPdXpzqnnv9x Wc9F4wyXEktxRqKhFnNRcSIACwPk/TUCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org This patch fixes the error path in the driver probe, so in case of any failure, the resources are not leaked. Reported-by: Liviu Dudau Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" 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/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 6ee620ee8cd5..1f3a7ee753db 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1159,7 +1159,10 @@ static int s5p_mfc_probe(struct platform_device *pdev) dev->variant = mfc_get_drv_data(pdev); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - + if (res == NULL) { + dev_err(&pdev->dev, "failed to get io resource\n"); + return -ENOENT; + } dev->regs_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(dev->regs_base)) return PTR_ERR(dev->regs_base); @@ -1167,15 +1170,14 @@ static int s5p_mfc_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (res == NULL) { dev_err(&pdev->dev, "failed to get irq resource\n"); - ret = -ENOENT; - goto err_res; + return -ENOENT; } dev->irq = res->start; ret = devm_request_irq(&pdev->dev, dev->irq, s5p_mfc_irq, 0, pdev->name, dev); if (ret) { dev_err(&pdev->dev, "Failed to install irq (%d)\n", ret); - goto err_res; + return ret; } ret = s5p_mfc_configure_dma_memory(dev); @@ -1187,7 +1189,7 @@ static int s5p_mfc_probe(struct platform_device *pdev) ret = s5p_mfc_init_pm(dev); if (ret < 0) { dev_err(&pdev->dev, "failed to get mfc clock source\n"); - return ret; + goto err_dma; } vb2_dma_contig_set_max_seg_size(dev->mem_dev_l, DMA_BIT_MASK(32)); @@ -1301,6 +1303,8 @@ err_mem_init_ctx_1: vb2_dma_contig_cleanup_ctx(dev->alloc_ctx[0]); err_res: s5p_mfc_final_pm(dev); +err_dma: + s5p_mfc_unconfigure_dma_memory(dev); pr_debug("%s-- with error\n", __func__); return ret;