diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2018-10-10 08:37:53 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2018-10-16 12:12:18 +0100 |
commit | a3b602da7d15d35139e145aae4ef44c6c836daf3 (patch) | |
tree | 25038c8d13eb298612fc175fd39f495756d55c49 | |
parent | 43e1fc2455494a9778e51a90bde08cd39507d4d2 (diff) |
merde
-rw-r--r-- | drivers/gpu/drm/i915/i915_user_extensions.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_user_extensions.c b/drivers/gpu/drm/i915/i915_user_extensions.c index 00622f8ac468..725a6154cc24 100644 --- a/drivers/gpu/drm/i915/i915_user_extensions.c +++ b/drivers/gpu/drm/i915/i915_user_extensions.c @@ -35,3 +35,52 @@ int i915_user_extensions(struct i915_user_extension __user *ext, return 0; } + +#if 0 +int i915_user_extensions_or_unwind(struct i915_user_extension __user *ext, + const i915_user_extension_tbl *tbl, + unsigned long count, + void *data) +{ + i915_user_extension_unwind unwind[16]; + int depth = 0; + int err; + + while (ext) { + u64 x; + + if (get_user(x, &ext->name)) { + err = -EFAULT; + goto unwind; + } + + err = -EINVAL; + if (x < count && tbl[x].fn) { + if (tbl[x].unwind && depth == ARRAY_SIZE(unwind)) { + err = -ELOOP; + goto unwind; + } + err = tbl[x].fn(ext, data); + } + if (err) + goto unwind; + + if (tbl[x].unwind) + unwind[depth++] = tbl[x].unwind; + + if (get_user(x, &ext->next_extension)) { + err = -EFAULT; + goto unwind; + } + + ext = u64_to_user_ptr(x); + } + + return 0; + +unwind: + while (depth--) + unwind[depth](data); + return err; +} +#endif |