Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp66637pxb; Mon, 13 Sep 2021 13:06:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxww6FzOlIePb+mCBvQ9FjbwXRUdXL+Yi8WCmKx3AeK80D8M20JuojRW8GbnKXCtUAA7b3p X-Received: by 2002:a17:906:f24f:: with SMTP id gy15mr12256697ejb.226.1631563605905; Mon, 13 Sep 2021 13:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631563605; cv=none; d=google.com; s=arc-20160816; b=Uthl9ave5fIcJ8qWF33U4Vp/Ue/cSCSDahkAWkEtBCj2l5YYTw/KWquE3aCteUix0k 2O/9tHM0HmCoK2SiA0zoBxsBCpNYRTRm5Mz/HCZtaXFwR5Pj48VJJ4IqiesMRU2eZV57 QjLXL9z5UwvgnAawfXO2prSo48nbAJnCXAcOg93KG9RsPCyRiR3/fZ/6WdkzmN1GqLGE rkXSZ5X7AQuB2CYjh0wOlgqDFgrm+lVTyQilJ5ueNczzC4PPD01pMlgEO5e9bbo5wzUk U09cr0/LEx3Ds9xW+TkjFHdjPo2+gyLYMY4XtyknuN5arFLB0ulWIqOI1AjGq59spm2+ B7rw== 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=mnVYT45TiVQMyq8Gjfb+cA/yyk2FormovwRmO67W10Y=; b=gJX2fRNVIggLQyFlZEGUkp95jtSL/5eEpg6/3UVAA/9gzw79/ahLwsypHAXX2+X4M0 saY/6srMlwMCmEAwbX7exqxIReS8lbV7qUWeGGDXG5HVTk71DDAHCVgfkp8gKalebUy2 6273zUdQ6VRrinDUS1pd+knvYnr4H03t0qgZtk9RjzXjyIA7HuFoEjN3onGt8ecHYj0J IWELnTpcft243D5UJ81JmMI6T6IDIvq+R3Xc6yqGBKKoxu/RYFjnPbiv8V3jqF1mus2V cMklxhIiLhQmc/ucoCWo1794iYM153An2/U4+UaRuZO1gq3IchAujyHguj0ZSF5OhVrY SqgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mxh1Hj1B; 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 p10si8264308ejo.13.2021.09.13.13.06.21; Mon, 13 Sep 2021 13:06: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=@linuxfoundation.org header.s=korg header.b=Mxh1Hj1B; 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 S242679AbhIMNpm (ORCPT + 99 others); Mon, 13 Sep 2021 09:45:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:41960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243229AbhIMNjO (ORCPT ); Mon, 13 Sep 2021 09:39:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52A1C6127B; Mon, 13 Sep 2021 13:28:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539738; bh=UHnM0abFLM3GYy1xujHHxOcpr7Sy645WE1ZG2tBFY/8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mxh1Hj1BpiFKlTns2gsG71Qn2VqFXMdKwfU+XJJnzi8KgshrB32KyHBnLyp/HKg4G WT/9NwSLRY8Xo8I4kqcqRyG1vpviiyTVvq5/RQ92KHGNg/K9XmH0/pSVuvG+Z5YiLg eE8QOG+mVRCTTmyQiABzVzpsaIHNgP0qyL43jE68= 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.10 142/236] drm/msm/dsi: Fix some reference counted resource leaks Date: Mon, 13 Sep 2021 15:14:07 +0200 Message-Id: <20210913131105.191677845@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@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 627048851d99..7e364b9c9f9e 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