Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH] gpu: i915: fix error return in mmap_offset_attach()
@ 2025-09-24 12:48 Alexandr Sapozhnkiov
  2025-09-24 20:20 ` Andi Shyti
  2025-09-25  8:32 ` [lvc-project] " Fedor Pchelkin
  0 siblings, 2 replies; 4+ messages in thread
From: Alexandr Sapozhnkiov @ 2025-09-24 12:48 UTC (permalink / raw)
  To: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Daniel Vetter, intel-gfx, dri-devel, linux-kernel
  Cc: Alexandr Sapozhnkiov, linux-media, lvc-project

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.

Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
index 75f5b0e871ef..eb76f8f2bd95 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
@@ -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:
-- 
2.43.0

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

* Re: [PATCH] gpu: i915: fix error return in mmap_offset_attach()
  2025-09-24 12:48 [PATCH] gpu: i915: fix error return in mmap_offset_attach() Alexandr Sapozhnkiov
@ 2025-09-24 20:20 ` Andi Shyti
  2025-09-25 13:51   ` Chris Wilson
  2025-09-25  8:32 ` [lvc-project] " Fedor Pchelkin
  1 sibling, 1 reply; 4+ messages in thread
From: Andi Shyti @ 2025-09-24 20:20 UTC (permalink / raw)
  To: Alexandr Sapozhnkiov
  Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	David Airlie, Daniel Vetter, intel-gfx, dri-devel, linux-kernel,
	linux-media, lvc-project, Krzysztof Karas

Hi Alexandr,

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

On Wed, Sep 24, 2025 at 03:48:50PM +0300, Alexandr Sapozhnkiov wrote:
> 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.

> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>

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

> ---

you are missing the changelog.

>  drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 75f5b0e871ef..eb76f8f2bd95 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -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

>  	return mmo;
>  
>  err:
> -- 
> 2.43.0

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

* Re: [lvc-project] [PATCH] gpu: i915: fix error return in mmap_offset_attach()
  2025-09-24 12:48 [PATCH] gpu: i915: fix error return in mmap_offset_attach() Alexandr Sapozhnkiov
  2025-09-24 20:20 ` Andi Shyti
@ 2025-09-25  8:32 ` Fedor Pchelkin
  1 sibling, 0 replies; 4+ messages in thread
From: Fedor Pchelkin @ 2025-09-25  8:32 UTC (permalink / raw)
  To: Alexandr Sapozhnkiov
  Cc: Jani Nikula, Andi Shyti, Krzysztof Karas, Joonas Lahtinen,
	Rodrigo Vivi, Tvrtko Ursulin, David Airlie, Daniel Vetter,
	intel-gfx, dri-devel, linux-kernel, lvc-project, linux-media

On Wed, 24. Sep 15:48, Alexandr Sapozhnkiov wrote:
> 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.
> 
> Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_mman.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> index 75f5b0e871ef..eb76f8f2bd95 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_mman.c
> @@ -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.

> +	}
>  	return mmo;
>  
>  err:
> -- 
> 2.43.0

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

* Re: [PATCH] gpu: i915: fix error return in mmap_offset_attach()
  2025-09-24 20:20 ` Andi Shyti
@ 2025-09-25 13:51   ` Chris Wilson
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2025-09-25 13:51 UTC (permalink / raw)
  To: Alexandr Sapozhnkiov, Andi Shyti
  Cc: Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	intel-gfx, dri-devel, linux-kernel, linux-media, lvc-project,
	Krzysztof Karas

Quoting Andi Shyti (2025-09-24 22:20:33)
> >       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;

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

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

end of thread, other threads:[~2025-09-25 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24 12:48 [PATCH] gpu: i915: fix error return in mmap_offset_attach() Alexandr Sapozhnkiov
2025-09-24 20:20 ` Andi Shyti
2025-09-25 13:51   ` Chris Wilson
2025-09-25  8:32 ` [lvc-project] " Fedor Pchelkin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox