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 1656E12838A; Tue, 23 Jan 2024 00:11:24 +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=1705968685; cv=none; b=HczjaPAbpFpqh8dja7GddzsTjEuQGtvIf1mtGN5GuGWOjE3uWm7ucoAKv6AmJxUUDXJqsXyvD3kyMQ46pieTnB1pEjD+E/jWvH7hD8ejBzgzrDNgDCk01vhI3KNoifgZ4fFAG7x8uLJwf28iOOI+Q/YbH2eSwKeiRsjlb+Xlx3I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705968685; c=relaxed/simple; bh=+6JujkXWlr9Lp93GCFaYdeHYL3bG7cufzNzUfHvlzlE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CTBZCsxFmoX3yH1Vyf4SU5EemlA049MjzNVhco4BrIESH3spvHqN1r0fDpToztghoSf9Ct05/4cUlpcMRcrDxhYwm5mgSfKe7RTzUK4EoPObvfsux2tYVoTKvwQDgNYayjlgCEAZ8LiO8OMJOKrcIJVOxl8qGz0OwAUyEHjNTjo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=M1UwA2HR; 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="M1UwA2HR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B840C433F1; Tue, 23 Jan 2024 00:11:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705968684; bh=+6JujkXWlr9Lp93GCFaYdeHYL3bG7cufzNzUfHvlzlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M1UwA2HRDuBCsF5zTYF7UfG6J006+MNkkXiEucYr64OHqyqKbESw5m5Phf/PP/434 XD1Z/q6lWaVyQ4oP89O+1VJbf64BMJFCMqLRtqxOqq9ndub/7uWpaXrVZl0x9RWvOn F5rrJqvl+662JRk4y4zKb7t2bHWqa99//weoTeFw= 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 103/148] drm/amd/pm: fix a double-free in si_dpm_init Date: Mon, 22 Jan 2024 15:57:39 -0800 Message-ID: <20240122235716.585558780@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 ac16667237a82e2597e329eb9bc520d1cf9dff30 ] When the allocation of adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries fails, amdgpu_free_extended_power_table is called to free some fields of adev. However, when the control flow returns to si_dpm_sw_init, it goes to label dpm_failed and calls si_dpm_fini, which calls amdgpu_free_extended_power_table again and free those fields again. Thus a double-free is triggered. Fixes: 841686df9f7d ("drm/amdgpu: add SI DPM support (v4)") Signed-off-by: Zhipeng Lu Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/si_dpm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index 9f811051ceb0..40a2637045c5 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c @@ -7346,10 +7346,9 @@ static int si_dpm_init(struct amdgpu_device *adev) kcalloc(4, sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL); - if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { - amdgpu_free_extended_power_table(adev); + if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) return -ENOMEM; - } + adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.count = 4; adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].clk = 0; adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries[0].v = 0; -- 2.43.0