Skip to contentSkip to conversation

gpu: i915: fix error return in mmap_offset_attach()

PATCH In review Alexandr Sapozhnkiov 5 participants 5 messages Sep 24, 2025 – Sep 26, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu: i915: fix error return in mmap_offset_attach()

Return value of function drm_vma_node_allow_once(), called at i915_gem_mman.c:672, is not checked.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +5 -2
index 75f5b0e871ef..eb76f8f2bd95 100644
@@ -758,8 +758,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)
+			goto err;
+	}
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
#1 lore raw

Hi Alexandr,

Please, verision the patch: this is [PATCH v2].

Quoted 2 lines · Alexandr Sapozhnkiov

Return value of function drm_vma_node_allow_once(), called at i915_gem_mman.c:672, is not checked.

You've been asked to improve the commit log, but you didn't. Please reply to this email with the commit log improved as suggested.

Quoted 3 lines

Found by Linux Verification Center (linuxtesting.org) with SVACE.

You forgot to add the r-b tag you received.

Quoted 1 line

---

you are missing the changelog.

Quoted 8 lines
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
index 75f5b0e871ef..eb76f8f2bd95 100644

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 765

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +5 -2
@@ -758,8 +758,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)
+			goto err;
+	}

I agree with the change.

Thank you,
Andi

Quoted 5 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
#3 lore raw
In reply to Alexandr Sapozhnkiov
Quoted 15 lines · Alexandr Sapozhnkiov

Return value of function drm_vma_node_allow_once(), called at i915_gem_mman.c:672, is not checked.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_mman.c +0 -0
index 75f5b0e871ef..eb76f8f2bd95 100644

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 764

Quoted 9 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +4 -2
@@ -758,8 +758,11 @@ mmap_offset_attach(struct drm_i915_gem_object *obj,
 	mmo = insert_mmo(obj, mmo);
 	GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);
 out:
-	if (file)
-		drm_vma_node_allow_once(&mmo->vma_node, file);
+	if (file) {
+		err = drm_vma_node_allow_once(&mmo->vma_node, file);
+		if (err)
+			goto err;

insert_mmo() inserts mmo into rb tree associated with obj. So it should be removed from the tree before mmo is freed on error path.

Is it probably better to return directly without going to the 'err' label? There should be no memory leaks in such case I guess.

Quoted 6 lines
drivers/gpu/drm/i915/gem/i915_gem_mman.c +1 -0
+	}
 	return mmo;
 
 err:
Signature · 1 line
2.43.0
#2 lore raw
In reply to Andi Shyti

Quoting Andi Shyti (2025-09-24 22:20:33)

Quoted 9 lines

drivers/gpu/drm/i915/gem/i915_gem_mman.c mmap_offset_attach(struct drm_i915_gem_object *obj, · line 764

Quoted 9 lines
      mmo = insert_mmo(obj, mmo);
      GEM_BUG_ON(lookup_mmo(obj, mmap_type) != mmo);

out:

drivers/gpu/drm/i915/gem/i915_gem_mman.c +4 -2
-     if (file)
-             drm_vma_node_allow_once(&mmo->vma_node, file);
+     if (file) {
+             err = drm_vma_node_allow_once(&mmo->vma_node, file);
+             if (err)
+                     goto err;

You cannot jump to err here, as that will try to free(mmo) which either was not allocated by the caller, or ownership has already been transferred to the mmo tree. It is sufficient to just return the err. -Chris

#4 lore raw

✗ LGCI.VerificationFailed: failure for gpu: i915: fix error return in mmap_offset_attach()

In reply to Alexandr Sapozhnkiov
== Series Details ==

== Series Details ==

Series: gpu: i915: fix error return in mmap_offset_attach()
URL : https://patchwork.freedesktop.org/series/155111/
State : failure

== Summary ==

Address '[email protected]' is not on the allowlist, which prevents CI from being triggered for this patch. If you want Intel GFX CI to accept this address, please contact the script maintainers at [email protected]. Exception occurred during validation, bailing out!