Commit 922682d4 authored by Steven Price's avatar Steven Price
Browse files

drm/gem: Correct error condition in drm_gem_objects_lookup



When vmemdup_array_user() fails, 'handles' is set to a negative error
code and no memory is allocated. So the call to kvfree() should not
happen. Instead just return early with the error code.

Fixes: cb77b79a ("drm/gem: Use vmemdup_array_user in drm_gem_objects_lookup")
Signed-off-by: default avatarSteven Price <steven.price@arm.com>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@igalia.com>
Link: https://patch.msgid.link/20251124112039.117748-1-steven.price@arm.com
parent e20c6260
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -798,13 +798,10 @@ int drm_gem_objects_lookup(struct drm_file *filp, void __user *bo_handles,
	*objs_out = objs;

	handles = vmemdup_array_user(bo_handles, count, sizeof(u32));
	if (IS_ERR(handles)) {
		ret = PTR_ERR(handles);
		goto out;
	}
	if (IS_ERR(handles))
		return PTR_ERR(handles);

	ret = objects_lookup(filp, handles, count, objs);
out:
	kvfree(handles);
	return ret;