[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b9b8ea58-1e06-4743-9b6c-7b29eeaff0d2@amd.com>
Date: Tue, 7 Jan 2025 10:59:54 -0600
From: "Limonciello, Mario" <mario.limonciello@....com>
To: Chris Bainbridge <chris.bainbridge@...il.com>
Cc: amd-gfx@...ts.freedesktop.org, alex.hung@....com,
regressions@...ts.linux.dev, tjakobi@...h.uni-bielefeld.de, lenb@...nel.org,
linux-acpi@...r.kernel.org, linux-kernel@...r.kernel.org,
"Rafael J. Wysocki" <rafael@...nel.org>
Subject: Re: [PATCH] drm/amd: Fix random crashes due to bad kfree
On 12/25/2024 5:09 PM, Chris Bainbridge wrote:
> Commit c6a837088bed ("drm/amd/display: Fetch the EDID from _DDC if
> available for eDP") added function dm_helpers_probe_acpi_edid, which
> fetches the EDID from the BIOS by calling acpi_video_get_edid.
> acpi_video_get_edid returns a pointer to the EDID, but this pointer does
> not originate from kmalloc - it is actually the internal "pointer" field
> from an acpi_buffer struct (which did come from kmalloc).
> dm_helpers_probe_acpi_edid then attempts to kfree the EDID pointer,
> resulting in memory corruption which leads to random, intermittent
> crashes (e.g. 4% of boots will fail with some Oops).
>
> Fix this by allocating a new array (which can be safely freed) for the
> EDID data in acpi_video_get_edid, and correctly freeing the acpi_buffer.
>
> The only other caller of acpi_video_get_edid is nouveau_acpi_edid:
> remove the extraneous kmemdup here as the EDID data is now copied in
> acpi_video_get_edid.
>
> Signed-off-by: Chris Bainbridge <chris.bainbridge@...il.com>
> Fixes: c6a837088bed ("drm/amd/display: Fetch the EDID from _DDC if available for eDP")
Thanks, I agree this is a better solution for this issue than
duplicating in the AMD driver code.
However, the subject seems wrong given where it lands. This is
primarily a patch to ACPI video, so it should be prefixed with "ACPI:
video" like other commits to acpi_video.c.
With that subject fixed:
Reviewed-by: Mario Limonciello <mario.limonciello@....com>
> ---
> drivers/acpi/acpi_video.c | 3 ++-
> drivers/gpu/drm/nouveau/nouveau_acpi.c | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
> index 8274a17872ed..151d1d534264 100644
> --- a/drivers/acpi/acpi_video.c
> +++ b/drivers/acpi/acpi_video.c
> @@ -1485,7 +1485,8 @@ int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
> if (!length)
> continue;
>
> - *edid = buffer->buffer.pointer;
> + *edid = kmemdup(buffer->buffer.pointer, length, GFP_KERNEL);
> + kfree(buffer);
> return length;
> }
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> index 8f0c69aad248..21b56cc7605c 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> @@ -384,7 +384,7 @@ nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector)
> if (ret < 0)
> return NULL;
>
> - return kmemdup(edid, EDID_LENGTH, GFP_KERNEL);
> + return edid;
> }
>
> bool nouveau_acpi_video_backlight_use_native(void)
Powered by blists - more mailing lists