From: Hans Verkuil Date: Mon, 27 May 2019 09:31:13 +0000 (-0400) Subject: media: mc-device.c: don't memset __user pointer contents X-Git-Tag: v4.14.135~268 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=8cc26f962d484def32a5e5f48492baec1bbe8fa4;p=users%2Fdwmw2%2Flinux.git media: mc-device.c: don't memset __user pointer contents [ Upstream commit 518fa4e0e0da97ea2e17c95ab57647ce748a96e2 ] 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 Reviewed-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index a6d56154fac72..4eb51a618fe12 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c @@ -486,8 +486,9 @@ static long media_device_enum_links32(struct media_device *mdev, if (ret) return ret; - memset(ulinks->reserved, 0, sizeof(ulinks->reserved)); - + if (copy_to_user(ulinks->reserved, links.reserved, + sizeof(ulinks->reserved))) + return -EFAULT; return 0; }