Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1249578pxa; Thu, 20 Aug 2020 06:45:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeItRTiJHPXuWFvPSe/iEwQ8HLeGzF5O5fzPnachzHxjzzUI4Cubz1EWjfk2VRYMp5hc/e X-Received: by 2002:a17:906:6bda:: with SMTP id t26mr3459588ejs.214.1597931126656; Thu, 20 Aug 2020 06:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931126; cv=none; d=google.com; s=arc-20160816; b=d4MIY3VCX5e64eNGHfl/PI4P7Qm7rfnYLMydioNmXSy00Lf/kPyzX3/O8LJFZ3Y+Ue fgUyzBaOK6fVRV7b+6NhhQ4JmGK/NMhzPHrLpucoOVyYuogx6qTRxtaYsOy7QcsZIS+4 Baw1vhjzca3Y0jRafG71CdUhOb3tDpEJplicavUbtx7Y8JqnI511iksAJxqZMG5BV3gR +nLSQy35xgQzfJ7ppYETubgAInczJ6Bn5GmjetgkIfEuAWF1KpeCCfCdqN/D6XqNPm/d VNLXctRbUw+9u761YKr/KU3YkneMvKEmSjwtnTNwwCAJUuCTqgAUFVtDlHXuK+gYKD+g wANA== 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=GNzCwntBM2aEizSSFq17kdbgrTF5Bu81G5T47485ixM=; b=qD3C1kIs9tlXa8+OhKjGt3W0yoMw11JlcqIbLr59OPhjgfAyxXubxT7b/QZ+HzF872 p5SOU58r+H3h3xxW99E6MH0w+cjtJB34r9lBTv/rsg7uYi4+7K+lfBiZIzySDQs6eH+/ FfrJyaZctuneONPIORvN1S0YURHx7PhtroEkL+toGFgGTasTBRfJypocByAPWJVoWprO C8aETTey+LBKKFHEinDV8+W+4FoThnPnXTzG+IEWYP7WeMJoZ/A5Vqr23JcbLsFa/L+/ SqWWYl2i5feXq5NqDp+0/ZRyZlGqp1V60f7M4BwGa2q+DMjsX6GCGuxPKnVv8fBOn6IS KkSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fH1t+MJ6; 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 va1si1247704ejb.558.2020.08.20.06.45.01; Thu, 20 Aug 2020 06:45:26 -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=fH1t+MJ6; 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 S1727955AbgHTNoJ (ORCPT + 99 others); Thu, 20 Aug 2020 09:44:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:39464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728049AbgHTJ3I (ORCPT ); Thu, 20 Aug 2020 05:29:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 763DF2173E; Thu, 20 Aug 2020 09:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915748; bh=L9dSTyxFIUL5QEh5h/RoTGvt3xEb1evM5ulwEW4iRhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fH1t+MJ635KfuSJpuSpx6XjgwDFg2PG+qZN5WL9q/E5RKVoWuNiWp/lv/1FK6QlLu aLW7cTUJDy8QCpWgVakrQIjWwluRW7CFweOkxZwgUIJfj15g2CIk2igAhjCO5DEnvB tLTPkwEn+HnrGixEl+xrjre0H5i+O2Byem2+jWrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen Tao , Alex Deucher , Sasha Levin Subject: [PATCH 5.8 120/232] drm/amdgpu/debugfs: fix memory leak when pm_runtime_get_sync failed Date: Thu, 20 Aug 2020 11:19:31 +0200 Message-Id: <20200820091618.628022066@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@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: Chen Tao [ Upstream commit 3e4aeff36e9212a939290c0ca70d4931c4ad1950 ] Fix memory leak in amdgpu_debugfs_gpr_read not freeing data when pm_runtime_get_sync failed. Fixes: a9ffe2a983383 ("drm/amdgpu/debugfs: properly handle runtime pm") Signed-off-by: Chen Tao Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c index f87b225437fc3..bd5061fbe031e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c @@ -973,7 +973,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, r = pm_runtime_get_sync(adev->ddev->dev); if (r < 0) - return r; + goto err; r = amdgpu_virt_enable_access_debugfs(adev); if (r < 0) @@ -1003,7 +1003,7 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, value = data[result >> 2]; r = put_user(value, (uint32_t *)buf); if (r) { - result = r; + amdgpu_virt_disable_access_debugfs(adev); goto err; } @@ -1012,11 +1012,14 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf, size -= 4; } -err: - pm_runtime_put_autosuspend(adev->ddev->dev); kfree(data); amdgpu_virt_disable_access_debugfs(adev); return result; + +err: + pm_runtime_put_autosuspend(adev->ddev->dev); + kfree(data); + return r; } /** -- 2.25.1