From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: fuyufan <fuyufan@huawei.com>,
intel-gfx@lists.freedesktop.org,
Maxime Ripard <maxime@cerno.tech>
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/atomic: Don't pollute crtc_state->mode_blob with error pointers
Date: Wed, 16 Feb 2022 13:19:35 +0200 [thread overview]
Message-ID: <Ygzdx3W2A/XcYOXg@intel.com> (raw)
In-Reply-To: <20220209091928.14766-1-ville.syrjala@linux.intel.com>
On Wed, Feb 09, 2022 at 11:19:27AM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Make sure we don't assign an error pointer to crtc_state->mode_blob
> as that will break all kinds of places that assume either NULL or a
> valid pointer (eg. drm_property_blob_put()).
>
> Reported-by: fuyufan <fuyufan@huawei.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Slapped on a cc:stable just in case this can actually happen
in the wild, and pushed to drm-misc-fixes with Maxime's irc ack
(thanks).
> ---
> drivers/gpu/drm/drm_atomic_uapi.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 9781722519c3..54d62fdb4ef9 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -76,15 +76,17 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
> state->mode_blob = NULL;
>
> if (mode) {
> + struct drm_property_blob *blob;
> +
> drm_mode_convert_to_umode(&umode, mode);
> - state->mode_blob =
> - drm_property_create_blob(state->crtc->dev,
> - sizeof(umode),
> - &umode);
> - if (IS_ERR(state->mode_blob))
> - return PTR_ERR(state->mode_blob);
> + blob = drm_property_create_blob(crtc->dev,
> + sizeof(umode), &umode);
> + if (IS_ERR(blob))
> + return PTR_ERR(blob);
>
> drm_mode_copy(&state->mode, mode);
> +
> + state->mode_blob = blob;
> state->enable = true;
> drm_dbg_atomic(crtc->dev,
> "Set [MODE:%s] for [CRTC:%d:%s] state %p\n",
> --
> 2.34.1
--
Ville Syrjälä
Intel
WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: fuyufan <fuyufan@huawei.com>,
intel-gfx@lists.freedesktop.org,
Maxime Ripard <maxime@cerno.tech>
Subject: Re: [PATCH 1/2] drm/atomic: Don't pollute crtc_state->mode_blob with error pointers
Date: Wed, 16 Feb 2022 13:19:35 +0200 [thread overview]
Message-ID: <Ygzdx3W2A/XcYOXg@intel.com> (raw)
In-Reply-To: <20220209091928.14766-1-ville.syrjala@linux.intel.com>
On Wed, Feb 09, 2022 at 11:19:27AM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Make sure we don't assign an error pointer to crtc_state->mode_blob
> as that will break all kinds of places that assume either NULL or a
> valid pointer (eg. drm_property_blob_put()).
>
> Reported-by: fuyufan <fuyufan@huawei.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Slapped on a cc:stable just in case this can actually happen
in the wild, and pushed to drm-misc-fixes with Maxime's irc ack
(thanks).
> ---
> drivers/gpu/drm/drm_atomic_uapi.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c
> index 9781722519c3..54d62fdb4ef9 100644
> --- a/drivers/gpu/drm/drm_atomic_uapi.c
> +++ b/drivers/gpu/drm/drm_atomic_uapi.c
> @@ -76,15 +76,17 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
> state->mode_blob = NULL;
>
> if (mode) {
> + struct drm_property_blob *blob;
> +
> drm_mode_convert_to_umode(&umode, mode);
> - state->mode_blob =
> - drm_property_create_blob(state->crtc->dev,
> - sizeof(umode),
> - &umode);
> - if (IS_ERR(state->mode_blob))
> - return PTR_ERR(state->mode_blob);
> + blob = drm_property_create_blob(crtc->dev,
> + sizeof(umode), &umode);
> + if (IS_ERR(blob))
> + return PTR_ERR(blob);
>
> drm_mode_copy(&state->mode, mode);
> +
> + state->mode_blob = blob;
> state->enable = true;
> drm_dbg_atomic(crtc->dev,
> "Set [MODE:%s] for [CRTC:%d:%s] state %p\n",
> --
> 2.34.1
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2022-02-16 11:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-09 9:19 [Intel-gfx] [PATCH 1/2] drm/atomic: Don't pollute crtc_state->mode_blob with error pointers Ville Syrjala
2022-02-09 9:19 ` Ville Syrjala
2022-02-09 9:19 ` [Intel-gfx] [PATCH 2/2] drm/modes: Fix drm_mode_copy() docs Ville Syrjala
2022-02-09 9:19 ` Ville Syrjala
2022-02-09 10:00 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/2] drm/atomic: Don't pollute crtc_state->mode_blob with error pointers Patchwork
2022-02-09 11:24 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-02-16 11:19 ` Ville Syrjälä [this message]
2022-02-16 11:19 ` [PATCH 1/2] " Ville Syrjälä
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=Ygzdx3W2A/XcYOXg@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=fuyufan@huawei.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=maxime@cerno.tech \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.