All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915: Return NULL on error in active_instance
@ 2026-06-24  9:09 Joonas Lahtinen
  2026-06-24  9:20 ` Sebastian Brzezinka
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Joonas Lahtinen @ 2026-06-24  9:09 UTC (permalink / raw)
  To: Intel graphics driver community testing & development
  Cc: Joonas Lahtinen, Martin Hodo, Maarten Lankhorst,
	Thomas Hellström, Simona Vetter, stable

Avoid returning &node->base when node is NULL due to OOM
during GFP_ATOMIC allocation.

Discovered using AI-assisted static analysis confirmed by
Intel Product Security.

Reported-by: Martin Hodo <martin.hodo@intel.com>
Fixes: bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Simona Vetter <simona.vetter@ffwll.ch>
Cc: <stable@vger.kernel.org> # v5.13+
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_active.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index 5cb7a72774a0..aa77def0bc0d 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -318,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx)
 	 */
 	node = kmem_cache_alloc(slab_cache, GFP_ATOMIC);
 	if (!node)
-		goto out;
+		goto err;
 
 	__i915_active_fence_init(&node->base, NULL, node_retire);
 	node->ref = ref;
@@ -332,6 +332,11 @@ active_instance(struct i915_active *ref, u64 idx)
 	spin_unlock_irq(&ref->tree_lock);
 
 	return &node->base;
+
+err:
+	spin_unlock_irq(&ref->tree_lock);
+
+	return NULL;
 }
 
 void __i915_active_init(struct i915_active *ref,
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24  9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
@ 2026-06-24  9:20 ` Sebastian Brzezinka
  2026-06-24  9:27 ` Sebastian Brzezinka
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 10+ messages in thread
From: Sebastian Brzezinka @ 2026-06-24  9:20 UTC (permalink / raw)
  To: Joonas Lahtinen,
	Intel graphics driver community testing & development
  Cc: Martin Hodo, Maarten Lankhorst, Thomas Hellström,
	Simona Vetter, stable

Hi Joonas,

On Wed Jun 24, 2026 at 11:09 AM CEST, Joonas Lahtinen wrote:
> Avoid returning &node->base when node is NULL due to OOM
> during GFP_ATOMIC allocation.
>
> Discovered using AI-assisted static analysis confirmed by
> Intel Product Security.
>
> Reported-by: Martin Hodo <martin.hodo@intel.com>
> Fixes: bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Simona Vetter <simona.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v5.13+
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
Looks good.
Reviewed-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>

-- 
Best regards,
Sebastian


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24  9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
  2026-06-24  9:20 ` Sebastian Brzezinka
@ 2026-06-24  9:27 ` Sebastian Brzezinka
  2026-06-24 10:24   ` Joonas Lahtinen
  2026-06-24  9:54 ` Maarten Lankhorst
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 10+ messages in thread
From: Sebastian Brzezinka @ 2026-06-24  9:27 UTC (permalink / raw)
  To: Joonas Lahtinen,
	Intel graphics driver community testing & development
  Cc: Martin Hodo, Maarten Lankhorst, Thomas Hellström,
	Simona Vetter, stable

Hi,
On Wed Jun 24, 2026 at 11:09 AM CEST, Joonas Lahtinen wrote:
> Avoid returning &node->base when node is NULL due to OOM
> during GFP_ATOMIC allocation.
>
> Discovered using AI-assisted static analysis confirmed by
> Intel Product Security.
>
> Reported-by: Martin Hodo <martin.hodo@intel.com>
> Fixes: bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Simona Vetter <simona.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v5.13+
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_active.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index 5cb7a72774a0..aa77def0bc0d 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -318,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx)
>  	 */
>  	node = kmem_cache_alloc(slab_cache, GFP_ATOMIC);
>  	if (!node)
> -		goto out;
> +		goto err;
just a nit: this jump is not neccesery, you could return early.

-- 
Best regards,
Sebastian


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24  9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
  2026-06-24  9:20 ` Sebastian Brzezinka
  2026-06-24  9:27 ` Sebastian Brzezinka
@ 2026-06-24  9:54 ` Maarten Lankhorst
  2026-06-24 10:36 ` ✗ i915.CI.BAT: failure for " Patchwork
  2026-06-24 11:25 ` [PATCH] " Joonas Lahtinen
  4 siblings, 0 replies; 10+ messages in thread
From: Maarten Lankhorst @ 2026-06-24  9:54 UTC (permalink / raw)
  To: Joonas Lahtinen,
	Intel graphics driver community testing & development
  Cc: Martin Hodo, Thomas Hellström, Simona Vetter, stable

Hi,

On 6/24/26 11:09, Joonas Lahtinen wrote:
> Avoid returning &node->base when node is NULL due to OOM
> during GFP_ATOMIC allocation.
> 
> Discovered using AI-assisted static analysis confirmed by
> Intel Product Security.
> 
> Reported-by: Martin Hodo <martin.hodo@intel.com>
> Fixes: bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Simona Vetter <simona.vetter@ffwll.ch>
> Cc: <stable@vger.kernel.org> # v5.13+
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> ---
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

>  drivers/gpu/drm/i915/i915_active.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index 5cb7a72774a0..aa77def0bc0d 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -318,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx)
>  	 */
>  	node = kmem_cache_alloc(slab_cache, GFP_ATOMIC);
>  	if (!node)
> -		goto out;
> +		goto err;
>  
>  	__i915_active_fence_init(&node->base, NULL, node_retire);
>  	node->ref = ref;
> @@ -332,6 +332,11 @@ active_instance(struct i915_active *ref, u64 idx)
>  	spin_unlock_irq(&ref->tree_lock);
>  
>  	return &node->base;
> +
> +err:
> +	spin_unlock_irq(&ref->tree_lock);
> +
> +	return NULL;
>  }
>  
>  void __i915_active_init(struct i915_active *ref,


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24  9:27 ` Sebastian Brzezinka
@ 2026-06-24 10:24   ` Joonas Lahtinen
  2026-06-24 10:29     ` Sebastian Brzezinka
  0 siblings, 1 reply; 10+ messages in thread
From: Joonas Lahtinen @ 2026-06-24 10:24 UTC (permalink / raw)
  To: Intel graphics driver community testing & development,
	Sebastian Brzezinka
  Cc: Martin Hodo, Maarten Lankhorst, Thomas Hellström,
	Simona Vetter, stable

Quoting Sebastian Brzezinka (2026-06-24 12:27:07)
> Hi,
> On Wed Jun 24, 2026 at 11:09 AM CEST, Joonas Lahtinen wrote:
> > Avoid returning &node->base when node is NULL due to OOM
> > during GFP_ATOMIC allocation.
> >
> > Discovered using AI-assisted static analysis confirmed by
> > Intel Product Security.

<SNIP>

> > +++ b/drivers/gpu/drm/i915/i915_active.c
> > @@ -318,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx)
> >        */
> >       node = kmem_cache_alloc(slab_cache, GFP_ATOMIC);
> >       if (!node)
> > -             goto out;
> > +             goto err;
> just a nit: this jump is not neccesery, you could return early.

We specifically want to embrace the onion error handling idiom with goto
rather than doing the spinlock release inline here.

Preferred error handling should look more like:

	if (!try_lock(lock))
		goto err;

	mem = alloc();
	if (!mem)
		goto err_lock;

	if (!bla_bla(mem, bar))
		goto err_mem;

	...

err_mem:
	free(mem);
err_lock:
	unlock(lock);
err:
	return ret;

Rather than:

	if (!try_lock(lock))
		return ret;

	mem = alloc();
	if (!mem)
	{
		unlock(lock);
		return ret;
	}

	if (!bla_bla(mem, bar))
	{
		free(mem);
		unlock(lock);
		return ret;
	}

	...

Regards, Joonas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24 10:24   ` Joonas Lahtinen
@ 2026-06-24 10:29     ` Sebastian Brzezinka
  0 siblings, 0 replies; 10+ messages in thread
From: Sebastian Brzezinka @ 2026-06-24 10:29 UTC (permalink / raw)
  To: Joonas Lahtinen,
	Intel graphics driver community testing & development,
	Sebastian Brzezinka
  Cc: Martin Hodo, Maarten Lankhorst, Thomas Hellström,
	Simona Vetter, stable

On Wed Jun 24, 2026 at 12:24 PM CEST, Joonas Lahtinen wrote:
> Quoting Sebastian Brzezinka (2026-06-24 12:27:07)
>> Hi,
>> On Wed Jun 24, 2026 at 11:09 AM CEST, Joonas Lahtinen wrote:
>> > Avoid returning &node->base when node is NULL due to OOM
>> > during GFP_ATOMIC allocation.
>> >
>> > Discovered using AI-assisted static analysis confirmed by
>> > Intel Product Security.
>
> <SNIP>
>
>> > +++ b/drivers/gpu/drm/i915/i915_active.c
>> > @@ -318,7 +318,7 @@ active_instance(struct i915_active *ref, u64 idx)
>> >        */
>> >       node = kmem_cache_alloc(slab_cache, GFP_ATOMIC);
>> >       if (!node)
>> > -             goto out;
>> > +             goto err;
>> just a nit: this jump is not neccesery, you could return early.
>
> We specifically want to embrace the onion error handling idiom with goto
> rather than doing the spinlock release inline here.
>
> Preferred error handling should look more like:
>
> 	if (!try_lock(lock))
> 		goto err;
>
> 	mem = alloc();
> 	if (!mem)
> 		goto err_lock;
>
> 	if (!bla_bla(mem, bar))
> 		goto err_mem;
>
> 	...
>
> err_mem:
> 	free(mem);
> err_lock:
> 	unlock(lock);
> err:
> 	return ret;
>
> Rather than:
>
> 	if (!try_lock(lock))
> 		return ret;
>
> 	mem = alloc();
> 	if (!mem)
> 	{
> 		unlock(lock);
> 		return ret;
> 	}
>
> 	if (!bla_bla(mem, bar))
> 	{
> 		free(mem);
> 		unlock(lock);
> 		return ret;
> 	}
>
> 	...
>
> Regards, Joonas
Good to know, thanks for the explanation.

-- 
Best regards,
Sebastian


^ permalink raw reply	[flat|nested] 10+ messages in thread

* ✗ i915.CI.BAT: failure for drm/i915: Return NULL on error in active_instance
  2026-06-24  9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
                   ` (2 preceding siblings ...)
  2026-06-24  9:54 ` Maarten Lankhorst
@ 2026-06-24 10:36 ` Patchwork
  2026-06-24 11:24   ` Joonas Lahtinen
  2026-06-24 11:25 ` [PATCH] " Joonas Lahtinen
  4 siblings, 1 reply; 10+ messages in thread
From: Patchwork @ 2026-06-24 10:36 UTC (permalink / raw)
  To: Joonas Lahtinen; +Cc: intel-gfx

[-- Attachment #1: Type: text/plain, Size: 2500 bytes --]

== Series Details ==

Series: drm/i915: Return NULL on error in active_instance
URL   : https://patchwork.freedesktop.org/series/169089/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_18714 -> Patchwork_169089v1
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_169089v1 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_169089v1, please notify your bug team (I915-ci-infra@lists.freedesktop.org) to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/index.html

Participating hosts (42 -> 40)
------------------------------

  Missing    (2): bat-dg2-13 fi-snb-2520m 

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_169089v1:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_selftest@live@late_gt_pm:
    - fi-bsw-nick:        [PASS][1] -> [ABORT][2] +1 other test abort
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18714/fi-bsw-nick/igt@i915_selftest@live@late_gt_pm.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/fi-bsw-nick/igt@i915_selftest@live@late_gt_pm.html

  
Known issues
------------

  Here are the changes found in Patchwork_169089v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@kms_hdmi_inject@inject-audio:
    - fi-tgl-1115g4:      [PASS][3] -> [FAIL][4] ([i915#16115])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18714/fi-tgl-1115g4/igt@kms_hdmi_inject@inject-audio.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/fi-tgl-1115g4/igt@kms_hdmi_inject@inject-audio.html

  
  [i915#16115]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/16115


Build changes
-------------

  * Linux: CI_DRM_18714 -> Patchwork_169089v1

  CI-20190529: 20190529
  CI_DRM_18714: b2817f6a1517bc9ecdef5229b84e8a44d983de82 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_8982: 48befce9e6b0c0d371c4812bfff34a61319f68f1 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
  Patchwork_169089v1: b2817f6a1517bc9ecdef5229b84e8a44d983de82 @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/index.html

[-- Attachment #2: Type: text/html, Size: 3126 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: ✗ i915.CI.BAT: failure for drm/i915: Return NULL on error in active_instance
  2026-06-24 10:36 ` ✗ i915.CI.BAT: failure for " Patchwork
@ 2026-06-24 11:24   ` Joonas Lahtinen
  0 siblings, 0 replies; 10+ messages in thread
From: Joonas Lahtinen @ 2026-06-24 11:24 UTC (permalink / raw)
  To: Patchwork, intel-gfx, i915-ci-infra; +Cc: intel-gfx

(+ i915-ci-infra)

Below is most definitely unrelated error.

Quoting Patchwork (2026-06-24 13:36:16)
> Patch Details
> 
> Series:  drm/i915: Return NULL on error in active_instance
> URL:     https://patchwork.freedesktop.org/series/169089/
> State:   failure
> Details: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/index.html
> 
> CI Bug Log - changes from CI_DRM_18714 -> Patchwork_169089v1
> 
> Summary
> 
> FAILURE
> 
> Serious unknown changes coming with Patchwork_169089v1 absolutely need to be
> verified manually.
> 
> If you think the reported changes have nothing to do with the changes
> introduced in Patchwork_169089v1, please notify your bug team
> (I915-ci-infra@lists.freedesktop.org) to allow them
> to document this new failure mode, which will reduce false positives in CI.
> 
> External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/
> index.html
> 
> Participating hosts (42 -> 40)
> 
> Missing (2): bat-dg2-13 fi-snb-2520m
> 
> Possible new issues
> 
> Here are the unknown changes that may have been introduced in
> Patchwork_169089v1:
> 
> IGT changes
> 
> Possible regressions
> 
>   • igt@i915_selftest@live@late_gt_pm:
>       □ fi-bsw-nick: PASS -> ABORT +1 other test abort
> 
> Known issues
> 
> Here are the changes found in Patchwork_169089v1 that come from known issues:
> 
> IGT changes
> 
> Issues hit
> 
>   • igt@kms_hdmi_inject@inject-audio:
>       □ fi-tgl-1115g4: PASS -> FAIL (i915#16115)
> 
> Build changes
> 
>   • Linux: CI_DRM_18714 -> Patchwork_169089v1
> 
> CI-20190529: 20190529
> CI_DRM_18714: b2817f6a1517bc9ecdef5229b84e8a44d983de82 @ git://
> anongit.freedesktop.org/gfx-ci/linux
> IGT_8982: 48befce9e6b0c0d371c4812bfff34a61319f68f1 @ https://
> gitlab.freedesktop.org/drm/igt-gpu-tools.git
> Patchwork_169089v1: b2817f6a1517bc9ecdef5229b84e8a44d983de82 @ git://
> anongit.freedesktop.org/gfx-ci/linux
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24  9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
                   ` (3 preceding siblings ...)
  2026-06-24 10:36 ` ✗ i915.CI.BAT: failure for " Patchwork
@ 2026-06-24 11:25 ` Joonas Lahtinen
  2026-06-24 12:59   ` Andi Shyti
  4 siblings, 1 reply; 10+ messages in thread
From: Joonas Lahtinen @ 2026-06-24 11:25 UTC (permalink / raw)
  To: Intel graphics driver community testing & development
  Cc: Martin Hodo, Maarten Lankhorst, Thomas Hellström,
	Simona Vetter, stable

Pushed to drm-intel-gt-next, thanks for the reviews.

Regards, Joonas

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] drm/i915: Return NULL on error in active_instance
  2026-06-24 11:25 ` [PATCH] " Joonas Lahtinen
@ 2026-06-24 12:59   ` Andi Shyti
  0 siblings, 0 replies; 10+ messages in thread
From: Andi Shyti @ 2026-06-24 12:59 UTC (permalink / raw)
  To: Joonas Lahtinen
  Cc: Intel graphics driver community testing & development,
	Martin Hodo, Maarten Lankhorst, Thomas Hellström,
	Simona Vetter, stable

Hi Joonas,

On Wed, Jun 24, 2026 at 02:25:19PM +0300, Joonas Lahtinen wrote:
> Pushed to drm-intel-gt-next, thanks for the reviews.

please, next time:

- Give people more time to review the patch. Only two hours
  passed between posting it and pushing it (during lunch time,
  BTW).

- There were BAT failures. They were unrelated, but so far we
  have generally held back patches until BAT was green, even for
  the most obvious changes.

Thanks,
Andi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-06-24 12:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24  9:09 [PATCH] drm/i915: Return NULL on error in active_instance Joonas Lahtinen
2026-06-24  9:20 ` Sebastian Brzezinka
2026-06-24  9:27 ` Sebastian Brzezinka
2026-06-24 10:24   ` Joonas Lahtinen
2026-06-24 10:29     ` Sebastian Brzezinka
2026-06-24  9:54 ` Maarten Lankhorst
2026-06-24 10:36 ` ✗ i915.CI.BAT: failure for " Patchwork
2026-06-24 11:24   ` Joonas Lahtinen
2026-06-24 11:25 ` [PATCH] " Joonas Lahtinen
2026-06-24 12:59   ` Andi Shyti

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.