From patchwork Mon Jun 11 16:53:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 10458467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EE20360467 for ; Mon, 11 Jun 2018 16:54:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E07902851D for ; Mon, 11 Jun 2018 16:54:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D49B528538; Mon, 11 Jun 2018 16:54:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E4282851D for ; Mon, 11 Jun 2018 16:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=MuTQisUJCiHNbSHMhcepeX8vbSsrRG3/fAM2LPPdvTo=; b=EKI 4VnNmLqGCHroSOdjTtLtY4J1DYbyegpruP63gTS3efP2Ts2kBTfCPWycj1mPe7lTDe3ZK6SrkfeXq wkePMBuKsSMs7qsizeO0R9PF8EA3rLuWXRl8PXX3HxIEO/NuLYN1WBNAYOH6JaVYhETfrCSGq+ue5 Vv3wCg/1M3SMEBrnE51rMHg7tC4QLiAHTNIh72pIT3DsOVy8g0v95ODoJ0zKXktJs1bC87ss7pyW3 bgaWiVXRwfgWbY97D5iklFRyzfF3me7UCo8h4B73JJw1E93e5IiLNjN1e/lXbfIHnwQUy33mbqQ9M Z+qEvZhvQpQK5uKViZnyVmIZa8+9dBw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSQ5L-0004AB-OU; Mon, 11 Jun 2018 16:54:27 +0000 Received: from smtp06.smtpout.orange.fr ([80.12.242.128] helo=smtp.smtpout.orange.fr) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fSQ4w-0003da-Dg for linux-amlogic@lists.infradead.org; Mon, 11 Jun 2018 16:54:04 +0000 Received: from localhost.localdomain ([77.136.205.128]) by mwinf5d63 with ME id xUtj1x0072mkQqM03UtjM5; Mon, 11 Jun 2018 18:53:47 +0200 X-ME-Helo: localhost.localdomain X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 11 Jun 2018 18:53:47 +0200 X-ME-IP: 77.136.205.128 From: Christophe JAILLET To: weiyongjun1@huawei.com, narmstrong@baylibre.com, airlied@linux.ie, carlo@caione.org, khilman@baylibre.com Subject: [PATCH] drm/meson: Fix an un-handled error path in 'meson_drv_bind_master()' Date: Mon, 11 Jun 2018 18:53:35 +0200 Message-Id: <20180611165335.24542-1-christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.17.0 X-Antivirus: Avast (VPS 180611-4, 11/06/2018), Outbound message X-Antivirus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180611_095402_762647_1F4390F4 X-CRM114-Status: GOOD ( 16.06 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Christophe JAILLET , linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If 'platform_get_resource_byname()' fails, we should release some resources before leaving, as already done in the other error handling path of the function. Fixes: acaa3f13b8dd ("drm/meson: Fix potential NULL dereference in meson_drv_bind_master()") Signed-off-by: Christophe JAILLET Acked-by: Neil Armstrong --- drivers/gpu/drm/meson/meson_drv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c index 32b1a6cdecfc..d3443125e661 100644 --- a/drivers/gpu/drm/meson/meson_drv.c +++ b/drivers/gpu/drm/meson/meson_drv.c @@ -197,8 +197,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) priv->io_base = regs; res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hhi"); - if (!res) - return -EINVAL; + if (!res) { + ret = -EINVAL; + goto free_drm; + } /* Simply ioremap since it may be a shared register zone */ regs = devm_ioremap(dev, res->start, resource_size(res)); if (!regs) { @@ -215,8 +217,10 @@ static int meson_drv_bind_master(struct device *dev, bool has_components) } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dmc"); - if (!res) - return -EINVAL; + if (!res) { + ret = -EINVAL; + goto free_drm; + } /* Simply ioremap since it may be a shared register zone */ regs = devm_ioremap(dev, res->start, resource_size(res)); if (!regs) {