Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: mc-device.c: don't memset __user pointer contents

You can't memset the contents of a __user pointer. Instead, call copy_to_user to
copy links.reserved (which is zeroed) to the user memory.

This fixes this sparse warning:

SPARSE:drivers/media/mc/mc-device.c drivers/media/mc/mc-device.c:521:16: warning: incorrect type in argument 1 (different address spaces)

Fixes: f49308878d720 ("media: media_device_enum_links32: clean a reserved field")

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
518fa4e0 3e6a515f

+3 -2
+3 -2
drivers/media/mc/mc-device.c
··· 518 518 if (ret) 519 519 return ret; 520 520 521 - memset(ulinks->reserved, 0, sizeof(ulinks->reserved)); 522 - 521 + if (copy_to_user(ulinks->reserved, links.reserved, 522 + sizeof(ulinks->reserved))) 523 + return -EFAULT; 523 524 return 0; 524 525 } 525 526