From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E684C433DF for ; Fri, 21 Aug 2020 17:14:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B4EA2072D for ; Fri, 21 Aug 2020 17:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598030097; bh=Fnf6Da5iVAtSBBxs5wP/Y391VGzZ2bXblesU4pZrlYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=g9KflKebJ7xi+LOhEn72x+LhxTg4PcdkEqjxpQ0vmZxlo48oKCNE1m75h6I+8RALa Xe9apxeLRP5oCM+V6LTNdka98BorWHRYZYyy1Q7x9qhwES95jzF0C5eJdjUPhGldqw e5z9ghs7trCLlONjfdSbELRs5qxbdy3zfEqw4TBo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728788AbgHUROz (ORCPT ); Fri, 21 Aug 2020 13:14:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:50368 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728127AbgHUQQr (ORCPT ); Fri, 21 Aug 2020 12:16:47 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B6CFA22B47; Fri, 21 Aug 2020 16:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598026607; bh=Fnf6Da5iVAtSBBxs5wP/Y391VGzZ2bXblesU4pZrlYs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UJh6GOWaig4oZSHkR7mMHhytZZ6xaIfuoklnaKv0YllUxKbrDGFtEBN1B2uE5xwz0 oYMZmpt0t4tVFC0T+ZKObWEYkuYAiU6ZwXY7TlU5yToj8lvM3o2G+SMBSWGGIp9P3Q d57q0SjocZ1IYNpQWlSitjLsPr1V/28RPOJ0DcDA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Aditya Pakki , Ben Skeggs , Sasha Levin , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.7 49/61] drm/nouveau: Fix reference count leak in nouveau_connector_detect Date: Fri, 21 Aug 2020 12:15:33 -0400 Message-Id: <20200821161545.347622-49-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821161545.347622-1-sashal@kernel.org> References: <20200821161545.347622-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aditya Pakki [ Upstream commit 990a1162986e8eff7ca18cc5a0e03b4304392ae2 ] nouveau_connector_detect() calls pm_runtime_get_sync and in turn increments the reference count. In case of failure, decrement the ref count before returning the error. Signed-off-by: Aditya Pakki Signed-off-by: Ben Skeggs Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/nouveau_connector.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 9a9a7f5003d3f..596999a77cabf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -567,8 +567,10 @@ nouveau_connector_detect(struct drm_connector *connector, bool force) pm_runtime_get_noresume(dev->dev); } else { ret = pm_runtime_get_sync(dev->dev); - if (ret < 0 && ret != -EACCES) + if (ret < 0 && ret != -EACCES) { + pm_runtime_put_autosuspend(dev->dev); return conn_status; + } } nv_encoder = nouveau_connector_ddc_detect(connector); -- 2.25.1