Skip to contentSkip to conversation

drm/i915: Return NULL on error in active_instance

PATCH Applied Joonas Lahtinen 5 participants 13 messages Jun 24 – Jun 25

Subsystems (3)
lore
Share & tools
lore

Joonas Lahtinen

author maintainer
#0 lore raw

PATCH 1/1 drm/i915: Return NULL on error in active_instance

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.

Fixes bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
Cc Maarten Lankhorst <[email protected]>
Cc Thomas Hellström <[email protected]>
Cc Simona Vetter <[email protected]>
Cc <[email protected]> # v5.13+
---
 drivers/gpu/drm/i915/i915_active.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_active.c +6 -1
index 5cb7a72774a0..aa77def0bc0d 100644
@@ -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,
Signature · 1 line
2.54.0
Reviewed-by on v1 1/1
#1 lore raw

Hi Joonas,

Quoted 6 lines · Joonas Lahtinen

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.

Quoted 8 lines
Fixes bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
Cc Maarten Lankhorst <[email protected]>
Cc Thomas Hellström <[email protected]>
Cc Simona Vetter <[email protected]>
Cc <[email protected]> # v5.13+

---

Looks good.

Signature · 2 lines
Best regards,
Sebastian
#2 lore raw
In reply to Joonas Lahtinen

Hi,

Quoted 22 lines · Joonas Lahtinen

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.

Fixes bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
Cc Maarten Lankhorst <[email protected]>
Cc Thomas Hellström <[email protected]>
Cc Simona Vetter <[email protected]>
Cc <[email protected]> # v5.13+
---
 drivers/gpu/drm/i915/i915_active.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_active.c +0 -0
index 5cb7a72774a0..aa77def0bc0d 100644

drivers/gpu/drm/i915/i915_active.c active_instance(struct i915_active *ref, u64 idx) · line 321

Quoted 5 lines
drivers/gpu/drm/i915/i915_active.c +1 -1
@@ -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.

Signature · 2 lines
Best regards,
Sebastian
author maintainer
#3 lore raw

Quoting Sebastian Brzezinka (2026-06-24 12:27:07)

Quoted 7 lines

Hi,

Quoted 5 lines · Joonas Lahtinen

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>

Quoted 8 lines

drivers/gpu/drm/i915/i915_active.c active_instance(struct i915_active *ref, u64 idx) · line 321

Quoted 7 lines

+++ b/drivers/gpu/drm/i915/i915_active.c

drivers/gpu/drm/i915/i915_active.c +1 -1
@@ -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

#4 lore raw
Quoted 65 lines · Joonas Lahtinen

Quoting Sebastian Brzezinka (2026-06-24 12:27:07)

Quoted 7 lines

Hi,

Quoted 5 lines · Joonas Lahtinen

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>

Quoted 8 lines

drivers/gpu/drm/i915/i915_active.c active_instance(struct i915_active *ref, u64 idx) · line 321

Quoted 7 lines

+++ b/drivers/gpu/drm/i915/i915_active.c

drivers/gpu/drm/i915/i915_active.c +1 -1
@@ -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;
	}

	...
Quoted 1 line

Regards, Joonas

Good to know, thanks for the explanation.

Signature · 2 lines
Best regards,
Sebastian
Reviewed-by on v1 1/1
#5 lore raw
In reply to Joonas Lahtinen

Hi,

Quoted 6 lines · Joonas Lahtinen

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.

Quoted 8 lines
Fixes bfaae47db3c0 ("drm/i915: make lockdep slightly happier about execbuf.")
Cc Maarten Lankhorst <[email protected]>
Cc Thomas Hellström <[email protected]>
Cc Simona Vetter <[email protected]>
Cc <[email protected]> # v5.13+

---

Quoted 28 lines
 drivers/gpu/drm/i915/i915_active.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_active.c +6 -1
index 5cb7a72774a0..aa77def0bc0d 100644
@@ -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,
#6 lore raw

✗ i915.CI.BAT: failure for drm/i915: Return NULL on error in active_instance

In reply to Joonas Lahtinen
== Series Details ==

== 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 ([email protected]) 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@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169089v1/fi-tgl-1115g4/igt@[email protected]

[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

author maintainer
#7 lore raw

Re: ✗ i915.CI.BAT: failure for drm/i915: Return NULL on error in active_instance

(+ i915-ci-infra)

Below is most definitely unrelated error.

Quoting Patchwork (2026-06-24 13:36:16)

Quoted 63 lines

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 ([email protected]) 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

#9 lore raw

Hi Joonas,

Quoted 1 line · Joonas Lahtinen

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

author maintainer
#10 lore raw

Quoting Andi Shyti (2026-06-24 15:59:30)

Quoted 9 lines

Hi Joonas,

Quoted 1 line · Joonas Lahtinen

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

And why exactly is that a problem? I got the review from the original patch author and a yet another person on top while it's a very uncontroversial and trivial patch. Two reviewers per patch is already quite a high bar to clear if you look at git history.

Quoted 1 line

(during lunch time, BTW).

Sorry, I did not know there is a universally agreed 2 hour lunch window in UTC timezone that I should follow. I've missed that memo.

Quoted 3 lines

- 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.

Strong disagree here. That'd have caused the patch to miss -next-fixes PR just due to random noise of CI.

If there was a reasonable doubt about the impact of the patch on the failure, that'd of course be different, but here there was absolutely none in this case.

As per patchwork automated mail reply:

Quoted 2 lines

If you think the reported changes have nothing to do with the changes introduced in Patchwork_169089v1, please notify your bug team

That's exactly what was done here. That's a fair ask, but asking for maintainers not to merge any code because of false positives is simply not.

Regards, Joonas

Quoted 3 lines

Thanks,
Andi

#11 lore raw

Re: [PATCH] drm/i915: Return NULL on error in active_instanceg

Hi Joonas,

Quoted 14 lines · Joonas Lahtinen

Quoting Andi Shyti (2026-06-24 15:59:30)

Quoted 7 lines · Joonas Lahtinen
Quoted 1 line

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

And why exactly is that a problem? I got the review from the original patch author and a yet another person on top while it's a very uncontroversial and trivial patch. Two reviewers per patch is already quite a high bar to clear if you look at git history.

Quoted 4 lines
Quoted 1 line

(during lunch time, BTW).

Sorry, I did not know there is a universally agreed 2 hour lunch window in UTC timezone that I should follow. I've missed that memo.

It's not a matter of how many reviewers there are or how controversial a patch may be. A patch needs to stay on the list long enough for the whole community to have a chance to review it. Give it one or two days.

Even if you and the other reviewers don't see anything wrong, someone else might. As submitters and maintainers, we need to give people a reasonable amount of time to look at every patch. Two hours, at any time of the day, are definitely not enough.

We often complain when people send new revisions too early for exactly the same reason.

Quoted 6 lines
Quoted 3 lines

- 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.

Strong disagree here. That'd have caused the patch to miss -next-fixes PR just due to random noise of CI.

We shouldn't care. The rules are the same for everyone, including maintainers. Very often I've been told to wait until the next cycle and very often I've asked others to do the same.

Besides, it's unfair to keep a patch on the list for only two hours just to avoid missing the current cycle, while everyone else is expected to wait.

Quoted 8 lines

If there was a reasonable doubt about the impact of the patch on the failure, that'd of course be different, but here there was absolutely none in this case.

As per patchwork automated mail reply:

Quoted 2 lines

If you think the reported changes have nothing to do with the changes introduced in Patchwork_169089v1, please notify your bug team

The bug team is a different matter. Here we're talking about the review process.

Quoted 3 lines

That's exactly what was done here. That's a fair ask, but asking for maintainers not to merge any code because of false positives is simply not.

False positive or not, controversial or not, easy or difficult, patches have *always* been blocked when BAT was red. The shard tests don't even start if BAT is red.

Otherwise, we might as well stop running automatic tests for patches considered "non-controversial" and save CI resources.

Andi

Quoted 5 lines

Regards, Joonas

Quoted 3 lines

Thanks,
Andi

author maintainer
#12 lore raw

Re: [PATCH] drm/i915: Return NULL on error in active_instanceg

Quoting Andi Shyti (2026-06-25 11:50:50)

Quoted 1 line · Joonas Lahtinen

<SNIP>

Quoted 2 lines

The bug team is a different matter. Here we're talking about the review process.

What comes to the review process, you're entitled to express your opinion how things should be.

If you do a rundown of average time spent on mailing list after R-b before merge split per subsystem / driver and show some stats for patches that are less than 10 lines, and we can maybe talk further.

Don't see the point otherwise. You do you, and me do me.

Quoted 6 lines
Quoted 3 lines

That's exactly what was done here. That's a fair ask, but asking for maintainers not to merge any code because of false positives is simply not.

False positive or not, controversial or not, easy or difficult, patches have *always* been blocked when BAT was red.

There's a very clear difference between random noise in BAT and something being wrong in BAT due to the patch. The whole reason for BAT to be established was to have a fast litmus test if the patch would break the world.

Original motivation was to avoid spinning up the more expensive shard runs if the litmus test doesn't pass. And it was recognized back then that we absolutely can't have false positives in BAT for things to work out reasonably.

Quoted 2 lines

Otherwise, we might as well stop running automatic tests for patches considered "non-controversial" and save CI resources.

Now that you bring it up, that's exactly what we should be targeting.

There is zero point in forcibly attaching test results to an individual patch if that patch has exactly zero coverage in the test set.

So for example here, if we would have some nice automated code coverage analysis that would have declared our tests don't have any coverage for the patch in question and skipped shards, that would have absolutely made sense (always allowing user to force the run, still).

The shard test run for this specific patch offers no other value than an completely disconnected idle run of the test set. A completely disconnected idle run would probably be even more valuable as it wouldn't connect false positives to unrelated patch.

But I don't think we're there yet. So in the meanwhile let's try to live with limitations of reality and fix some bugs.

Regards, Joonas