[PATCH] mc-device.c: don't memset __user pointer contents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)

Signed-off-by: Hans Verkuil <hverkuil-cisco@xxxxxxxxx>
Fixes: f49308878d720 ("media: media_device_enum_links32: clean a reserved field")
---
Note: this patch sits on top of https://patchwork.linuxtv.org/patch/56330/,
which moves the media sources to drivers/media/mc.
---
diff --git a/drivers/media/mc/mc-device.c b/drivers/media/mc/mc-device.c
index 6893843edada..8e2a66493e62 100644
--- a/drivers/media/mc/mc-device.c
+++ b/drivers/media/mc/mc-device.c
@@ -518,8 +518,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;
 }




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux