Commit 8b0f690d authored by Haowen Bai's avatar Haowen Bai Committed by Mauro Carvalho Chehab
Browse files

media: mediatek: vcodec: Use kmemdup rather than kmalloc/memcpy



kmemdup is introduced to duplicate a region of memory in a neat way.
Rather than kmalloc/kzalloc + memcpy, which the programmer needs to
write the size twice (sometimes lead to mistakes), kmemdup improves
readability, leads to smaller code and also reduce the chances of mistakes.
Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy.

Signed-off-by: default avatarHaowen Bai <baihaowen@meizu.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 5c2111c2
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -526,13 +526,12 @@ static int vdec_vp9_slice_init_default_frame_ctx(struct vdec_vp9_slice_instance
	if (vdec_vp9_slice_default_frame_ctx)
		goto out;

	frame_ctx = kmalloc(sizeof(*frame_ctx), GFP_KERNEL);
	frame_ctx = kmemdup(remote_frame_ctx, sizeof(*frame_ctx), GFP_KERNEL);
	if (!frame_ctx) {
		ret = -ENOMEM;
		goto out;
	}

	memcpy(frame_ctx, remote_frame_ctx, sizeof(*frame_ctx));
	vdec_vp9_slice_default_frame_ctx = frame_ctx;

out: