drm/qxl: Handle correctly failures in qxl_alloc_relase_reserved
authorFrediano Ziglio <fziglio@redhat.com>
Wed, 3 Jun 2015 11:09:15 +0000 (12:09 +0100)
committerDave Airlie <airlied@redhat.com>
Fri, 5 Jun 2015 01:00:50 +0000 (11:00 +1000)
Free resources correctly if function fails

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/qxl/qxl_release.c

index 6fd8e50e3506adc596bdb0031a30c36ddc6e4586..00604ed173a271386ce5ffcd79074635d4d4f36f 100644 (file)
@@ -363,6 +363,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
                ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx]);
                if (ret) {
                        mutex_unlock(&qdev->release_mutex);
+                       qxl_release_free(qdev, *release);
                        return ret;
                }
        }
@@ -377,13 +378,17 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
 
        mutex_unlock(&qdev->release_mutex);
 
-       qxl_release_list_add(*release, bo);
+       ret = qxl_release_list_add(*release, bo);
+       qxl_bo_unref(&bo);
+       if (ret) {
+               qxl_release_free(qdev, *release);
+               return ret;
+       }
 
        info = qxl_release_map(qdev, *release);
        info->id = idr_ret;
        qxl_release_unmap(qdev, *release, info);
 
-       qxl_bo_unref(&bo);
        return ret;
 }