mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
To: Chris Bainbridge <chris.bainbridge@gmail.com>,
	Mario Limonciello <mario.limonciello@amd.com>
Cc: amd-gfx@lists.freedesktop.org, alex.hung@amd.com,
	regressions@lists.linux.dev, rafael@kernel.org, lenb@kernel.org,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd: Fix random crashes due to bad kfree
Date: Thu, 26 Dec 2024 00:19:02 +0100	[thread overview]
Message-ID: <b98f2fa5-fbe8-4958-bf20-fa5d28c5a38b@math.uni-bielefeld.de> (raw)
In-Reply-To: <Z2yQvTyg_MWwrlj3@debian.local>

Hi Chris!

On 12/26/24 00:09, 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.

Hmm, maybe I'm missing something here. But shouldn't it suffice to just 
remove the kfree call in dm_helpers_probe_acpi_edid()?

With best wishes,
Tobias

>
> 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@gmail.com>
> Fixes: c6a837088bed ("drm/amd/display: Fetch the EDID from _DDC if available for eDP")
> ---
>   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)

  reply	other threads:[~2024-12-25 23:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-25 23:09 Chris Bainbridge
2024-12-25 23:19 ` Tobias Jakobi [this message]
2024-12-26  1:27   ` Chris Bainbridge
2024-12-26 12:29     ` Tobias Jakobi
2025-01-07 18:06     ` Rafael J. Wysocki
2025-01-11 18:59       ` [PATCH v2] ACPI: video: " Chris Bainbridge
2025-01-13  9:25         ` Hans de Goede
2025-01-13 14:19         ` Mario Limonciello
2025-01-13 15:59           ` Mario Limonciello
2025-01-13 20:12             ` Rafael J. Wysocki
2025-01-07 16:50 ` [PATCH] drm/amd: " Chris Bainbridge
2025-01-07 16:59 ` Limonciello, Mario

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b98f2fa5-fbe8-4958-bf20-fa5d28c5a38b@math.uni-bielefeld.de \
    --to=tjakobi@math.uni-bielefeld.de \
    --cc=alex.hung@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=chris.bainbridge@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mario.limonciello@amd.com \
    --cc=rafael@kernel.org \
    --cc=regressions@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®