drm/nouveau: fix pin refcnt leak in failure path
authorBen Skeggs <bskeggs@redhat.com>
Thu, 6 Nov 2014 04:34:31 +0000 (14:34 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Tue, 2 Dec 2014 05:44:00 +0000 (15:44 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nouveau_bo.c

index d2a4768e3efd67fe7a1484832c74a3b35fddf8c8..d409b26607f320dd8a1efdb76105e7fc4a99803d 100644 (file)
@@ -333,22 +333,22 @@ nouveau_bo_pin(struct nouveau_bo *nvbo, uint32_t memtype)
        nouveau_bo_placement_set(nvbo, memtype, 0);
 
        ret = nouveau_bo_validate(nvbo, false, false);
-       if (ret == 0) {
-               switch (bo->mem.mem_type) {
-               case TTM_PL_VRAM:
-                       drm->gem.vram_available -= bo->mem.size;
-                       break;
-               case TTM_PL_TT:
-                       drm->gem.gart_available -= bo->mem.size;
-                       break;
-               default:
-                       break;
-               }
+       if (ret)
+               goto out;
+
+       switch (bo->mem.mem_type) {
+       case TTM_PL_VRAM:
+               drm->gem.vram_available -= bo->mem.size;
+               break;
+       case TTM_PL_TT:
+               drm->gem.gart_available -= bo->mem.size;
+               break;
+       default:
+               break;
        }
 
 ref_inc:
        nvbo->pin_refcnt++;
-
 out:
        ttm_bo_unreserve(bo);
        return ret;