| .. | .. |
|---|
| 81 | 81 | struct panfrost_gem_object *bo; |
|---|
| 82 | 82 | struct drm_panfrost_create_bo *args = data; |
|---|
| 83 | 83 | struct panfrost_gem_mapping *mapping; |
|---|
| 84 | + int ret; |
|---|
| 84 | 85 | |
|---|
| 85 | 86 | if (!args->size || args->pad || |
|---|
| 86 | 87 | (args->flags & ~(PANFROST_BO_NOEXEC | PANFROST_BO_HEAP))) |
|---|
| .. | .. |
|---|
| 91 | 92 | !(args->flags & PANFROST_BO_NOEXEC)) |
|---|
| 92 | 93 | return -EINVAL; |
|---|
| 93 | 94 | |
|---|
| 94 | | - bo = panfrost_gem_create_with_handle(file, dev, args->size, args->flags, |
|---|
| 95 | | - &args->handle); |
|---|
| 95 | + bo = panfrost_gem_create(dev, args->size, args->flags); |
|---|
| 96 | 96 | if (IS_ERR(bo)) |
|---|
| 97 | 97 | return PTR_ERR(bo); |
|---|
| 98 | 98 | |
|---|
| 99 | + ret = drm_gem_handle_create(file, &bo->base.base, &args->handle); |
|---|
| 100 | + if (ret) |
|---|
| 101 | + goto out; |
|---|
| 102 | + |
|---|
| 99 | 103 | mapping = panfrost_gem_mapping_get(bo, priv); |
|---|
| 100 | | - if (!mapping) { |
|---|
| 101 | | - drm_gem_object_put(&bo->base.base); |
|---|
| 102 | | - return -EINVAL; |
|---|
| 104 | + if (mapping) { |
|---|
| 105 | + args->offset = mapping->mmnode.start << PAGE_SHIFT; |
|---|
| 106 | + panfrost_gem_mapping_put(mapping); |
|---|
| 107 | + } else { |
|---|
| 108 | + /* This can only happen if the handle from |
|---|
| 109 | + * drm_gem_handle_create() has already been guessed and freed |
|---|
| 110 | + * by user space |
|---|
| 111 | + */ |
|---|
| 112 | + ret = -EINVAL; |
|---|
| 103 | 113 | } |
|---|
| 104 | 114 | |
|---|
| 105 | | - args->offset = mapping->mmnode.start << PAGE_SHIFT; |
|---|
| 106 | | - panfrost_gem_mapping_put(mapping); |
|---|
| 107 | | - |
|---|
| 108 | | - return 0; |
|---|
| 115 | +out: |
|---|
| 116 | + drm_gem_object_put(&bo->base.base); |
|---|
| 117 | + return ret; |
|---|
| 109 | 118 | } |
|---|
| 110 | 119 | |
|---|
| 111 | 120 | /** |
|---|