From a3b602da7d15d35139e145aae4ef44c6c836daf3 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 10 Oct 2018 08:37:53 +0100 Subject: merde --- drivers/gpu/drm/i915/i915_user_extensions.c | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) 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 -- cgit v1.2.3