Unverified Commit 2872a57c authored by Jinjie Ruan's avatar Jinjie Ruan Committed by Matt Coster
Browse files

drm/imagination: Use memdup_user() helper



Switching to memdup_user(), which combines kmalloc() and copy_from_user(),
and it can simplfy code.

Signed-off-by: default avatarJinjie Ruan <ruanjinjie@huawei.com>
Suggested-by: default avatarChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: default avatarFrank Binns <frank.binns@imgtec.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240902023300.1214753-1-ruanjinjie@huawei.com


Signed-off-by: default avatarMatt Coster <matt.coster@imgtec.com>
parent 3742c209
Loading
Loading
Loading
Loading
+3 −15
Original line number Diff line number Diff line
@@ -69,24 +69,12 @@ process_static_context_state(struct pvr_device *pvr_dev, const struct pvr_stream
	void *stream;
	int err;

	stream = kzalloc(stream_size, GFP_KERNEL);
	if (!stream)
		return -ENOMEM;

	if (copy_from_user(stream, u64_to_user_ptr(stream_user_ptr), stream_size)) {
		err = -EFAULT;
		goto err_free;
	}
	stream = memdup_user(u64_to_user_ptr(stream_user_ptr), stream_size);
	if (IS_ERR(stream))
		return PTR_ERR(stream);

	err = pvr_stream_process(pvr_dev, cmd_defs, stream, stream_size, dest);
	if (err)
		goto err_free;

	kfree(stream);

	return 0;

err_free:
	kfree(stream);

	return err;