diff mbox

intel: Don't leak the test page in an has_userptr() error path

Message ID 1410957471-11375-1-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien Sept. 17, 2014, 12:37 p.m. UTC
When handling the error on GEM_CLOSE, we weren't freeing the allocated
page. Plug that.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 intel/intel_bufmgr_gem.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Tvrtko Ursulin Sept. 19, 2014, 1:31 p.m. UTC | #1
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

On 09/17/2014 01:37 PM, Damien Lespiau wrote:
> When handling the error on GEM_CLOSE, we weren't freeing the allocated
> page. Plug that.
>
> Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
> ---
>   intel/intel_bufmgr_gem.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
> index f378e5c..ce35bd4 100644
> --- a/intel/intel_bufmgr_gem.c
> +++ b/intel/intel_bufmgr_gem.c
> @@ -3383,9 +3383,8 @@ retry:
>
>   	close_bo.handle = userptr.handle;
>   	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
> -	if (ret == 0) {
> -		free(ptr);
> -	} else {
> +	free(ptr);
> +	if (ret) {
>   		fprintf(stderr, "Failed to release test userptr object! (%d) "
>   				"i915 kernel driver may not be sane!\n", errno);
>   		return false;
>
Lespiau, Damien Sept. 19, 2014, 1:37 p.m. UTC | #2
On Fri, Sep 19, 2014 at 02:31:56PM +0100, Tvrtko Ursulin wrote:
> 
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> 

Thanks for the review, pushed the patch.
diff mbox

Patch

diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index f378e5c..ce35bd4 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -3383,9 +3383,8 @@  retry:
 
 	close_bo.handle = userptr.handle;
 	ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_GEM_CLOSE, &close_bo);
-	if (ret == 0) {
-		free(ptr);
-	} else {
+	free(ptr);
+	if (ret) {
 		fprintf(stderr, "Failed to release test userptr object! (%d) "
 				"i915 kernel driver may not be sane!\n", errno);
 		return false;