Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1885642pxk; Tue, 1 Sep 2020 10:01:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxa17nCxQ/sATz5ZEsXu8pZdRT4sB7N6ZaklidY8cJeBox2A2hLscE8vfUUWcT/GZkbAMk8 X-Received: by 2002:aa7:d6c1:: with SMTP id x1mr2553374edr.190.1598979714210; Tue, 01 Sep 2020 10:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598979714; cv=none; d=google.com; s=arc-20160816; b=R61dLGR6BQZsMEdaY8rVyTvZQbf60ZTYkfrBA2SpLaF4mBKn4Q/AfL1wVVPfzA4z2k FpfirmOzyMwdRbYCi1u6nPGWo1cBRKJ02W9v/o27kpEdX3M1kCwpuJexzNoNb/xaz62G de8HAO+yJHUnOAi0oS/sLMLtulWycnFvUOxEm0Dla+rQwugw/CLK5luysaNaB3l40lQQ 9IuBaEz8hIA8Wkb66IiNQlMqS4UjTwDkAyGedkdvmdcLsLFyVYJ9PVSYBMbMFZD/D43D zk/pv98L+VIvBcEzI9fYVUE6uVTsk5UeUMVjUchH6oJLawid30sEyWAwBunyZNeRwhAg gJJA== 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=wbGANbOOBs6ppT2JAiTdYAin6qB+fJL14HSOILtyg6Y=; b=YCifonTVZ3YP2uATAmLUrOZ6duZbAKMDw/VxmG4EOGg4JfXouaLfcsmNFOme4Bltko lCl7FBbKcqcWWpBLVE2FejInOZ0wGQJ6e56u9u8j/NoRN7119JKFtMN0ugrSalonNuQU pr1bRBs2e5OKnUjEGjoXgk7HzlOaxB8J4PqGuPjymzTsDaoUB0g8CDsPvUAxFavKjxNu nPUIbUmlnrBJVmV0SJ7tNDU0ilRVOzfO5fLYkdeFIw6UuIGR+ojQCSeQol48fua8EypH d6E4cL2SBZe6zAqKO6bs7j8pisF/GX7pogPZoxe/CouElQy9nMOzWG52Zv8SPAyky8Mz BB/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=p6YlObHg; 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 x2si932526eju.153.2020.09.01.10.01.30; Tue, 01 Sep 2020 10:01:54 -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=p6YlObHg; 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 S1730373AbgIAQ6l (ORCPT + 99 others); Tue, 1 Sep 2020 12:58:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:43768 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729748AbgIAPWR (ORCPT ); Tue, 1 Sep 2020 11:22:17 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 2F6DD20FC3; Tue, 1 Sep 2020 15:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973735; bh=6deX/TmUbsvm1tTU+C7Pa7u01gKIJUvlmIN2OgFCEIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6YlObHghV08mRiR4n9z3l56L0VHK66A9GAxMEVteu7wCc4B3qIalcugbAanpYyb1 WTMHx61xkE2oCC1WIDioKQK8jbluRhVipNWC9WOZ9tLpFf0NupTD99Ow13GIUBH1KM X0k6lm0NWb2zJYan2j/gu8Xuzo6L0a6C2isqB9Cs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Navid Emamdoost , Alex Deucher , Sasha Levin Subject: [PATCH 4.19 025/125] drm/amdgpu/display: fix ref count leak when pm_runtime_get_sync fails Date: Tue, 1 Sep 2020 17:09:40 +0200 Message-Id: <20200901150935.792494856@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150934.576210879@linuxfoundation.org> References: <20200901150934.576210879@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: Navid Emamdoost [ Upstream commit f79f94765f8c39db0b7dec1d335ab046aac03f20 ] The call to pm_runtime_get_sync increments the counter even in case of failure, leading to incorrect ref count. In case of failure, decrement the ref count before returning. Signed-off-by: Navid Emamdoost Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c index c770d73352a79..c15286858f0bf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c @@ -718,8 +718,10 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force) if (!drm_kms_helper_is_poll_worker()) { r = pm_runtime_get_sync(connector->dev->dev); - if (r < 0) + if (r < 0) { + pm_runtime_put_autosuspend(connector->dev->dev); return connector_status_disconnected; + } } if (encoder) { @@ -856,8 +858,10 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force) if (!drm_kms_helper_is_poll_worker()) { r = pm_runtime_get_sync(connector->dev->dev); - if (r < 0) + if (r < 0) { + pm_runtime_put_autosuspend(connector->dev->dev); return connector_status_disconnected; + } } encoder = amdgpu_connector_best_single_encoder(connector); @@ -979,8 +983,10 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force) if (!drm_kms_helper_is_poll_worker()) { r = pm_runtime_get_sync(connector->dev->dev); - if (r < 0) + if (r < 0) { + pm_runtime_put_autosuspend(connector->dev->dev); return connector_status_disconnected; + } } if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { @@ -1329,8 +1335,10 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force) if (!drm_kms_helper_is_poll_worker()) { r = pm_runtime_get_sync(connector->dev->dev); - if (r < 0) + if (r < 0) { + pm_runtime_put_autosuspend(connector->dev->dev); return connector_status_disconnected; + } } if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { -- 2.25.1