mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
drm/i915/gem: Do not leak siblings[] on proto context error
After a successful BALANCE/PARALLEL_SUBMIT extension on context
creation, error during processing of next user extension leaks
the siblings[] array. Fix that.
Discovered using AI-assisted static analysis confirmed by
Intel Product Security.
Reported-by: Martin Hodo <martin.hodo@intel.com>
Fixes: d4433c7600 ("drm/i915/gem: Use the proto-context to handle create parameters (v5)")
Cc: Faith Ekstrand <faith.ekstrand@collabora.com>
Cc: Simona Vetter <simona.vetter@ffwll.ch>
Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: <stable@vger.kernel.org> # v5.15+
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net>
Link: https://lore.kernel.org/r/20260701073030.44850-1-joonas.lahtinen@linux.intel.com
(cherry picked from commit aa65e0a4b51b3b54b53e4142aaa2d997aa1061ff)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
82ec992c40
commit
eed3de2acf
|
|
@ -769,8 +769,8 @@ static int set_proto_ctx_engines(struct drm_i915_file_private *fpriv,
|
|||
struct intel_engine_cs *engine;
|
||||
|
||||
if (copy_from_user(&ci, &user->engines[n], sizeof(ci))) {
|
||||
kfree(set.engines);
|
||||
return -EFAULT;
|
||||
err = -EFAULT;
|
||||
goto err;
|
||||
}
|
||||
|
||||
memset(&set.engines[n], 0, sizeof(set.engines[n]));
|
||||
|
|
@ -786,8 +786,8 @@ static int set_proto_ctx_engines(struct drm_i915_file_private *fpriv,
|
|||
drm_dbg(&i915->drm,
|
||||
"Invalid engine[%d]: { class:%d, instance:%d }\n",
|
||||
n, ci.engine_class, ci.engine_instance);
|
||||
kfree(set.engines);
|
||||
return -ENOENT;
|
||||
err = -ENOENT;
|
||||
goto err;
|
||||
}
|
||||
|
||||
set.engines[n].type = I915_GEM_ENGINE_TYPE_PHYSICAL;
|
||||
|
|
@ -800,15 +800,21 @@ static int set_proto_ctx_engines(struct drm_i915_file_private *fpriv,
|
|||
set_proto_ctx_engines_extensions,
|
||||
ARRAY_SIZE(set_proto_ctx_engines_extensions),
|
||||
&set);
|
||||
if (err) {
|
||||
kfree(set.engines);
|
||||
return err;
|
||||
}
|
||||
if (err)
|
||||
goto err_extensions;
|
||||
|
||||
pc->num_user_engines = set.num_engines;
|
||||
pc->user_engines = set.engines;
|
||||
|
||||
return 0;
|
||||
|
||||
err_extensions:
|
||||
for (n = 0; n < set.num_engines; n++)
|
||||
kfree(set.engines[n].siblings);
|
||||
err:
|
||||
kfree(set.engines);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int set_proto_ctx_sseu(struct drm_i915_file_private *fpriv,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user