Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2635113pxa; Mon, 17 Aug 2020 15:03:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKIziJmZFE4sXDQUxJnnjdCNfHI84eia6yOp2BSfg59U3A6zgC7vV1DIqAVhtGX43LOWs9 X-Received: by 2002:aa7:cc12:: with SMTP id q18mr16778949edt.113.1597701825586; Mon, 17 Aug 2020 15:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701825; cv=none; d=google.com; s=arc-20160816; b=yZJTDYGBWfMmeR8h3dxQ20XX2xKLoH/Z1PfccAnf/KH3e9DFBYQQ0VBEGaB/pf119k FcDhnvaPQz+++e3z08nLZd98o7AYbcYeoMbFnfIp9aI62bTY7E0gA33dGwRcpPcs0uFM /S4sJqLSd7VnJygPGra76KJvRDPpuoEGTnC9pjD5zVGssM7hcwt3qcR6n62SAY3aLBrR V9dnh4CQKExZ2TP8tX7l9PBffo9pRkCDCDuIykBCaoIhuxWBNYgH6JTkADEmJhIMMUj1 r7Pxi/c1LD8iFLwgQ2vUygRyiijqPVsBAYIOwCyALnZoY9GsFJEp0QX9VeyiYUVI+wup VRNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SAk4XgTmONg473NPS6B5+Szr2RD0LVo3wy5niFai6H4=; b=iOQCUiKdKERwnOMmvl2xHuvayYQZ/EBUZrBFIXEBecMMO8v4uw1KvqoO8b9+Iyn+fs KSZkaecf+i/Fit2PyX5O6NMQJ8oCZeSTaRV6jpGIoDsKjo0YS0GYsIo2kHyaKEl4hLEv 0ofTHpZizdK3n6mK80g/DpYnE+YFwpPUBvZ/VeOJtc6dAGgvO7YmQ2Lxvgucn24nWqdH yBCZT63a11ZoKMmKzIvdpCBqOp4DkbrnfYP1R20rpc/Uqt9VEzpYpIkpP14dtFKsscyX 5uY1OlkXS62rqML76oH/5FIpTJLfSmfQN9QJ4PUeaTfwMnx1Wq+Qh2zCk4ZEqQetrG70 GOMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yos5Veve; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm16si12374076ejb.525.2020.08.17.15.03.22; Mon, 17 Aug 2020 15:03:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Yos5Veve; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387570AbgHQPmm (ORCPT + 99 others); Mon, 17 Aug 2020 11:42:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:42868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730259AbgHQPfw (ORCPT ); Mon, 17 Aug 2020 11:35:52 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B866B2078D; Mon, 17 Aug 2020 15:35:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678551; bh=4FCTFl2gzUbVg54z/gtL1p8dbf5EZnnL4xV1WIitkvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yos5Veve62MInGjDgBzfM/VTh1AEEwfFaOa6rwkJR6wcAmHL7IfpCfrL80woMUyyf haGLhx3vSVfpLdBlR+CuehkMOxgYH2nr2lHRNoaxPJyHWyUPTbI1l9+N1c3sXfmeH4 DWZcfGPfskSQyGtFdFWT9qUnM+Cyi1Gg8WXpkK+s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.8 373/464] media: mtk-mdp: Fix a refcounting bug on error in init Date: Mon, 17 Aug 2020 17:15:26 +0200 Message-Id: <20200817143851.641745549@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit dd4eddc4ba31fbf4554fc5fa12d3a553b50e1469 ] We need to call of_node_put(comp->dev_node); on the error paths in this function. Fixes: c8eb2d7e8202 ("[media] media: Add Mediatek MDP Driver") Signed-off-by: Dan Carpenter Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c index 58abfbdfb82d3..90b6d939f3adb 100644 --- a/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +++ b/drivers/media/platform/mtk-mdp/mtk_mdp_comp.c @@ -96,6 +96,7 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, { struct device_node *larb_node; struct platform_device *larb_pdev; + int ret; int i; if (comp_id < 0 || comp_id >= MTK_MDP_COMP_ID_MAX) { @@ -113,8 +114,8 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, if (IS_ERR(comp->clk[i])) { if (PTR_ERR(comp->clk[i]) != -EPROBE_DEFER) dev_err(dev, "Failed to get clock\n"); - - return PTR_ERR(comp->clk[i]); + ret = PTR_ERR(comp->clk[i]); + goto put_dev; } /* Only RDMA needs two clocks */ @@ -133,20 +134,27 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node, if (!larb_node) { dev_err(dev, "Missing mediadek,larb phandle in %pOF node\n", node); - return -EINVAL; + ret = -EINVAL; + goto put_dev; } larb_pdev = of_find_device_by_node(larb_node); if (!larb_pdev) { dev_warn(dev, "Waiting for larb device %pOF\n", larb_node); of_node_put(larb_node); - return -EPROBE_DEFER; + ret = -EPROBE_DEFER; + goto put_dev; } of_node_put(larb_node); comp->larb_dev = &larb_pdev->dev; return 0; + +put_dev: + of_node_put(comp->dev_node); + + return ret; } void mtk_mdp_comp_deinit(struct device *dev, struct mtk_mdp_comp *comp) -- 2.25.1