Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1825079pxb; Mon, 13 Sep 2021 06:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxcLNmSYxek6NUvRYtAMLKzCdSU8qlE9IbpTphXWEzNcvikr3GBMWWuXY7bMd1iyouIouz+ X-Received: by 2002:a05:6638:b10:: with SMTP id a16mr9975266jab.149.1631539450793; Mon, 13 Sep 2021 06:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631539450; cv=none; d=google.com; s=arc-20160816; b=py6wtF8s75Bs93qJ62FbFENZcp35P6kglkRr0LockQH0250P1xKBtoTLaTibsG0ger 5/wlgK+Wl9bup2d3zVeKG6f03Y7uqxuUaSWzwBFVoBnqMqCD0+zPtpTsgOCSqYbI9T5R JH1moTFEF415m2JFSVUVW3hMfI6qvPC0QSSWt2sGxI7HhUANoNBPy6vOxjVMZ/l0GquF PpK1PtIyxEGF9hnDIF1nCisJtMWegg8wsSo9iL3+qDP2WsEjEPwdCStI7fPbgXXlFU2L OzXm6z8uxCbnz8XQDRn585YUJ3Hng+qb6q6rtveudVIwGY1JNfYCFUdHxf1T2lLUOI11 QmGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eSTr4T+7Z6q3YJEoAn6qr4HcTjFdNi2Hnn4SXtmjd0s=; b=RargyNSRuu8JVOZAKNZwQsEDlSqON79IRRjWR+qsQOM9eNJj783YUxbG/JW7faV2nz zaCUulnJ29JcKzFJJwKfO5zQ2ey4OWFr2sMGHKC0S8RzZI6dU6Ht98dZcRMVR2nnjh4S Xh3cNts+hGJLZQ79Iac0KTK/y0P4LIV1ZleSGGu4Of127dKmB7om2TWQQRweKH8Ue2Qk fblKHdZkCXv3LpLE1WTRNMUxJE1cjCZskOpqrcai4M/zBzA/Gebes15qf2411l2IDupa NtmY/j8Uy1cSJRee3V790Jw6FVSgr7ZsJ670E+ESZU+JXaIhj1WLgieMAVub1c7aw+L5 UbJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H2fwDSF6; 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=pass (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 189si7442123ioa.35.2021.09.13.06.23.58; Mon, 13 Sep 2021 06:24:10 -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=@linuxfoundation.org header.s=korg header.b=H2fwDSF6; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241328AbhIMNXx (ORCPT + 99 others); Mon, 13 Sep 2021 09:23:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:37924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240824AbhIMNVl (ORCPT ); Mon, 13 Sep 2021 09:21:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 24AA3610CE; Mon, 13 Sep 2021 13:20:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539225; bh=7rcpZBCqt7UxdGaW6PQLRf4U6sHFHTnF2VL4CG4bsbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H2fwDSF6bEpFKZNZCQZgjmyJ/3ch57x/dOjDZNxoCLeWcpkLVg/s+4xfF9NY3Rn48 eMpeezxK/DpLgle0TG8EtmW8gwZ0xLejLvpB+QU9oXJD8vnecnhTV394slfcRJUQxT pJw6rfNDlXkh0r8eCuo1f7e6wzc69Piit5KJokpI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Rob Clark , Sasha Levin Subject: [PATCH 5.4 087/144] drm/msm/dsi: Fix some reference counted resource leaks Date: Mon, 13 Sep 2021 15:14:28 +0200 Message-Id: <20210913131050.865061609@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131047.974309396@linuxfoundation.org> References: <20210913131047.974309396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit 6977cc89c87506ff17e6c05f0e37f46752256e82 ] 'of_find_device_by_node()' takes a reference that must be released when not needed anymore. This is expected to be done in 'dsi_destroy()'. However, there are 2 issues in 'dsi_get_phy()'. First, if 'of_find_device_by_node()' succeeds but 'platform_get_drvdata()' returns NULL, 'msm_dsi->phy_dev' will still be NULL, and the reference won't be released in 'dsi_destroy()'. Secondly, as 'of_find_device_by_node()' already takes a reference, there is no need for an additional 'get_device()'. Move the assignment to 'msm_dsi->phy_dev' a few lines above and remove the unneeded 'get_device()' to solve both issues. Fixes: ec31abf6684e ("drm/msm/dsi: Separate PHY to another platform device") Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/f15bc57648a00e7c99f943903468a04639d50596.1628241097.git.christophe.jaillet@wanadoo.fr Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/dsi/dsi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c index 55ea4bc2ee9c..0d37ae5b310c 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -26,8 +26,10 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi) } phy_pdev = of_find_device_by_node(phy_node); - if (phy_pdev) + if (phy_pdev) { msm_dsi->phy = platform_get_drvdata(phy_pdev); + msm_dsi->phy_dev = &phy_pdev->dev; + } of_node_put(phy_node); @@ -36,8 +38,6 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi) return -EPROBE_DEFER; } - msm_dsi->phy_dev = get_device(&phy_pdev->dev); - return 0; } -- 2.30.2