From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D02C7482ED; Tue, 23 Jan 2024 00:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705968675; cv=none; b=r6wAk4ieBDotjP7mFQ3ezK5CWTzoSfzgQbx3tRWIiHLbKJu5z005QIkrMuZuSHdIncL/X/lq3LS3Hsl2fcakqHJTjQVd2jmTiC74MfXq16XjmvLkvu7zBbkFtCxDdQ4Aqk4eB6/P2c7UW0z7RMLFrVjFdeuQtlANTpCQj+NIh20= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705968675; c=relaxed/simple; bh=C9z6Ur/AU2sPVItJlZwrZo/V3t8BpkgSrGTsH1jmx88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SEf2FkUt0Eb0vgiQXjqLqPUjx5JEJyJZbTh58vWHCdY5t4YdBNKz4zN3f+6mkH/sVDBKhdGP7j/hic2jbEpyB6Y/wujHTo/1Ghb+U9DSFmRo5bkzzj+3pMcuN9wmo2ACK7EWDHXTKR6u1EtatmrdNu1ff2v1pPZXwsZtPMJi4x4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=JHsbZ81Z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="JHsbZ81Z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07C4BC4AF5E; Tue, 23 Jan 2024 00:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705968675; bh=C9z6Ur/AU2sPVItJlZwrZo/V3t8BpkgSrGTsH1jmx88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHsbZ81ZsM0ByFz0oHaZC7mBcj6E+3PeyxFgRQkGyIHZL+ONHpBkfMSzCeHrnBtnC Iz58n1hSwPGrBW/UiKCvxOp+Sh1F/VGh/WKL2aqOlkRPS57WsarTiThYpSe8A1K9sY VNP1gcKsi6htQ7rS0U2GShVyxXq3bpvJxqI44/bo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhipeng Lu , Alex Deucher , Sasha Levin Subject: [PATCH 4.19 098/148] drm/radeon/dpm: fix a memleak in sumo_parse_power_table Date: Mon, 22 Jan 2024 15:57:34 -0800 Message-ID: <20240122235716.359247322@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235712.442097787@linuxfoundation.org> References: <20240122235712.442097787@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhipeng Lu [ Upstream commit 0737df9ed0997f5b8addd6e2b9699a8c6edba2e4 ] The rdev->pm.dpm.ps allocated by kcalloc should be freed in every following error-handling path. However, in the error-handling of rdev->pm.power_state[i].clock_info the rdev->pm.dpm.ps is not freed, resulting in a memleak in this function. Fixes: 80ea2c129c76 ("drm/radeon/kms: add dpm support for sumo asics (v2)") Signed-off-by: Zhipeng Lu Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/radeon/sumo_dpm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index 1e4975f3374c..b9dc3805d7fb 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c @@ -1494,8 +1494,10 @@ static int sumo_parse_power_table(struct radeon_device *rdev) non_clock_array_index = power_state->v2.nonClockInfoIndex; non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) &non_clock_info_array->nonClockInfo[non_clock_array_index]; - if (!rdev->pm.power_state[i].clock_info) + if (!rdev->pm.power_state[i].clock_info) { + kfree(rdev->pm.dpm.ps); return -EINVAL; + } ps = kzalloc(sizeof(struct sumo_ps), GFP_KERNEL); if (ps == NULL) { kfree(rdev->pm.dpm.ps); -- 2.43.0