@@ -90,21 +90,24 @@ nouveau_bo_create(struct kms_driver *kms,
}
}
- bo = calloc(1, sizeof(*bo));
- if (!bo)
- return -ENOMEM;
-
- if (type == KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8) {
+ switch (type) {
+ case KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8:
pitch = 64 * 4;
size = 64 * 64 * 4;
- } else if (type == KMS_BO_TYPE_SCANOUT_X8R8G8B8) {
+ break;
+ case KMS_BO_TYPE_SCANOUT_X8R8G8B8:
pitch = width * 4;
pitch = (pitch + 512 - 1) & ~(512 - 1);
size = pitch * height;
- } else {
+ break;
+ default:
return -EINVAL;
}
+ bo = calloc(1, sizeof(*bo));
+ if (!bo)
+ return -ENOMEM;
+
memset(&arg, 0, sizeof(arg));
arg.info.size = size;
arg.info.domain = NOUVEAU_GEM_DOMAIN_MAPPABLE | NOUVEAU_GEM_DOMAIN_VRAM;
@@ -114,8 +117,10 @@ nouveau_bo_create(struct kms_driver *kms,
arg.channel_hint = 0;
ret = drmCommandWriteRead(kms->fd, DRM_NOUVEAU_GEM_NEW, &arg, sizeof(arg));
- if (ret)
- goto err_free;
+ if (ret) {
+ free(bo);
+ return ret;
+ }
bo->base.kms = kms;
bo->base.handle = arg.info.handle;
@@ -126,10 +131,6 @@ nouveau_bo_create(struct kms_driver *kms,
*out = &bo->base;
return 0;
-
-err_free:
- free(bo);
- return ret;
}
static int