diff mbox series

[RESEND] drm/nouveau: Add a jump label in nouveau_gem_ioctl_pushbuf()

Message ID 684bfc0d-7e1d-40f1-b1b7-d6ed64fcd8b7@web.de (mailing list archive)
State New
Headers show
Series [RESEND] drm/nouveau: Add a jump label in nouveau_gem_ioctl_pushbuf() | expand

Commit Message

Markus Elfring March 3, 2025, 5:49 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 5 Apr 2023 18:38:54 +0200

The label “out_prevalid” was used to jump to another pointer check
despite of the detail in the implementation of the function
“nouveau_gem_ioctl_pushbuf” that it was determined already in one case
that the corresponding variable contained an error pointer
because of a failed call of the function “u_memcpya”.

Thus use an additional label.

This issue was detected by using the Coccinelle software.

Fixes: 2be65641642e ("drm/nouveau: fix relocations applying logic and a double-free")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.40.0

Comments

Lyude Paul March 3, 2025, 7:39 p.m. UTC | #1
Reviewed-by: Lyude Paul <lyude@redhat.com>

Will push to drm-misc in a moment

On Mon, 2025-03-03 at 18:49 +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 5 Apr 2023 18:38:54 +0200
> 
> The label “out_prevalid” was used to jump to another pointer check
> despite of the detail in the implementation of the function
> “nouveau_gem_ioctl_pushbuf” that it was determined already in one case
> that the corresponding variable contained an error pointer
> because of a failed call of the function “u_memcpya”.
> 
> Thus use an additional label.
> 
> This issue was detected by using the Coccinelle software.
> 
> Fixes: 2be65641642e ("drm/nouveau: fix relocations applying logic and a double-free")
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/nouveau/nouveau_gem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
> index f77e44958037..d87e1cb2c933 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
> @@ -814,7 +814,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
>  			reloc = u_memcpya(req->relocs, req->nr_relocs, sizeof(*reloc));
>  			if (IS_ERR(reloc)) {
>  				ret = PTR_ERR(reloc);
> -				goto out_prevalid;
> +				goto out_free_bo;
>  			}
> 
>  			goto revalidate;
> @@ -929,6 +929,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
>  out_prevalid:
>  	if (!IS_ERR(reloc))
>  		u_free(reloc);
> +out_free_bo:
>  	u_free(bo);
>  	u_free(push);
> 
> --
> 2.40.0
> 
>
Danilo Krummrich March 3, 2025, 7:41 p.m. UTC | #2
On Mon, Mar 03, 2025 at 06:49:07PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 5 Apr 2023 18:38:54 +0200
> 
> The label “out_prevalid” was used to jump to another pointer check
> despite of the detail in the implementation of the function
> “nouveau_gem_ioctl_pushbuf” that it was determined already in one case
> that the corresponding variable contained an error pointer
> because of a failed call of the function “u_memcpya”.
> 
> Thus use an additional label.
> 
> This issue was detected by using the Coccinelle software.
> 
> Fixes: 2be65641642e ("drm/nouveau: fix relocations applying logic and a double-free")
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

I'm not entirely sure, but I remember that we had this discussion already.

Can you please send patches from the same address as indicated by your SoB?
Lyude Paul March 3, 2025, 8:56 p.m. UTC | #3
Oh I didn't even notice this, thanks Danilo :)

On Mon, 2025-03-03 at 20:41 +0100, Danilo Krummrich wrote:
> On Mon, Mar 03, 2025 at 06:49:07PM +0100, Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Wed, 5 Apr 2023 18:38:54 +0200
> > 
> > The label “out_prevalid” was used to jump to another pointer check
> > despite of the detail in the implementation of the function
> > “nouveau_gem_ioctl_pushbuf” that it was determined already in one case
> > that the corresponding variable contained an error pointer
> > because of a failed call of the function “u_memcpya”.
> > 
> > Thus use an additional label.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Fixes: 2be65641642e ("drm/nouveau: fix relocations applying logic and a double-free")
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> I'm not entirely sure, but I remember that we had this discussion already.
> 
> Can you please send patches from the same address as indicated by your SoB?
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index f77e44958037..d87e1cb2c933 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -814,7 +814,7 @@  nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 			reloc = u_memcpya(req->relocs, req->nr_relocs, sizeof(*reloc));
 			if (IS_ERR(reloc)) {
 				ret = PTR_ERR(reloc);
-				goto out_prevalid;
+				goto out_free_bo;
 			}

 			goto revalidate;
@@ -929,6 +929,7 @@  nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
 out_prevalid:
 	if (!IS_ERR(reloc))
 		u_free(reloc);
+out_free_bo:
 	u_free(bo);
 	u_free(push);