Re: [PATCH] drm/gem-shmem: When drm_gem_object_init failed, should release object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

Am 08.11.22 um 03:03 schrieb ChunyouTang:
when goto err_free, the object had init, so it should be release when fail.

If the call to drm_gem_object_init() fails, the object is still uninitialized. Admittedly, the call to gem_create_object could need additional cleanup, but it appears as if no one has had a need for this so far.

Is there anything that might leak?


Signed-off-by: ChunyouTang <tangchunyou@xxxxxxx>
---
  drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c
index 35138f8a375c..2e5e3207355f 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -104,10 +104,10 @@ __drm_gem_shmem_create(struct drm_device *dev, size_t size, bool private)
return shmem; -err_release:
-	drm_gem_object_release(obj);
  err_free:
  	kfree(obj);
+err_release:
+	drm_gem_object_release(obj);

You have now freed the object's memory before releasing it. Not going to work.

Best regards
Thomas

return ERR_PTR(ret);
  }

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux