Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2318994pxb; Mon, 20 Sep 2021 18:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAWD6AxkpEMz2uBDrmg13hc/ejoGiacVdzkVtm7IISnHu9Sa7lQXi1eQXm33KV/ycw90eR X-Received: by 2002:a05:6e02:1786:: with SMTP id y6mr13073378ilu.147.1632188500380; Mon, 20 Sep 2021 18:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632188500; cv=none; d=google.com; s=arc-20160816; b=mqRFdNKa/e/QuZElqJ8qQVzFXX1Ws1kBAZFB3f1nmRtaQJOdK9S+b8yh43hjaDrREF 2xhvp5epSkq2PuZRMDk6XDXQlXrNpTTMN8KNG4xvqKbS1Gd3eGtpmbGpFuQIuHLyz88n vtl7150nn9Eg3q0HJ4g0HZoBULhTcIIq9cDSf/50ZREdwc+G2IP3Nj7mSm3FqIsUJeF8 0F2xN998POLNpzjnkkEV5jv4K1N4KEPXvrgDs2T2VFtCZJ+wNZhuJKb0Bj+rzxkWbarw mnulvT73cZ7gN4YYpA141UrIoO0GTN9cCzpxeSmX8CtcEwGajoX/WAJnHvomidS8JUQD Rw1g== 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=tiXUveLkyDAiFxqibJtr+wGAIsHoJOGrOPl1hxoemQ4=; b=U7vM37/1KM+IJwjKXA+lEJUEg8ZLBTSQUmeeN9dd0+iyEL8mLlzCc4mH/sp+oXp1X6 WPdynMIayZ61A5kNLbf828xsO10m+IA7eO+WY411Au+RVQ+cBuOtRDbII2pLWlqt4WOI 4fZUGpxTbkPDW80u3TBd+6O1/jzLisLx19VWw1RUFhuxlPB3vvi8C2tjPZZAcDfza/ot wb3v7KbwSAZY8Z1JDsMznFxqEl6nUs1qiN0ag/gAtCL1snvqet7qIEsvV29FyPm0k26C NCo6tCa7ynfbqFF9p45tzxTSMQ0hxKYW+2Z96V6AfU1D7ZSZyxE/zCxAkrT4YcFiXxWe AzYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ItekIsnt; 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 g5si17369665jaj.5.2021.09.20.18.41.28; Mon, 20 Sep 2021 18:41:40 -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=ItekIsnt; 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 S242994AbhITQtj (ORCPT + 99 others); Mon, 20 Sep 2021 12:49:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:37068 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243283AbhITQsZ (ORCPT ); Mon, 20 Sep 2021 12:48:25 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC9EB61283; Mon, 20 Sep 2021 16:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632156417; bh=IaFdkkG7QvRgyFW3Tit9ebtaDeSUrj35HUvwlTcdsP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItekIsntg9Fl/xusW+5TqbAxTt3ifgJbzwmrR88rd2o1yazgjTRtz2SfluHkgCI5T ivKg0yK9pcLbhSVkD8Oaz8ekBsWBifqDbnlI7Uac1nurObzNecDVPgXgMraSRhOOxk M5Gf1NzBwuFzZ6TobqpXCvB5tNoiGJq97VnGjxfI= 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 4.4 049/133] drm/msm/dsi: Fix some reference counted resource leaks Date: Mon, 20 Sep 2021 18:42:07 +0200 Message-Id: <20210920163914.249233914@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163912.603434365@linuxfoundation.org> References: <20210920163912.603434365@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 6edcd6f57e70..817661462676 100644 --- a/drivers/gpu/drm/msm/dsi/dsi.c +++ b/drivers/gpu/drm/msm/dsi/dsi.c @@ -36,8 +36,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); @@ -46,8 +48,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