Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f8a695c4 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

media: v4l2-ioctl: rename a temp var that stores _IOC_SIZE(cmd)



Instead of just calling it as "size", let's name it as "ioc_size",
as it reflects better its contents.

As this is constant along the function, also mark it as const.

Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 6ccd228e
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -2833,15 +2833,15 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
	size_t  array_size = 0;
	size_t  array_size = 0;
	void __user *user_ptr = NULL;
	void __user *user_ptr = NULL;
	void	**kernel_ptr = NULL;
	void	**kernel_ptr = NULL;
	size_t	size = _IOC_SIZE(cmd);
	const size_t ioc_size = _IOC_SIZE(cmd);


	/*  Copy arguments into temp kernel buffer  */
	/*  Copy arguments into temp kernel buffer  */
	if (_IOC_DIR(cmd) != _IOC_NONE) {
	if (_IOC_DIR(cmd) != _IOC_NONE) {
		if (size <= sizeof(sbuf)) {
		if (ioc_size <= sizeof(sbuf)) {
			parg = sbuf;
			parg = sbuf;
		} else {
		} else {
			/* too big to allocate from stack */
			/* too big to allocate from stack */
			mbuf = kvmalloc(size, GFP_KERNEL);
			mbuf = kvmalloc(ioc_size, GFP_KERNEL);
			if (NULL == mbuf)
			if (NULL == mbuf)
				return -ENOMEM;
				return -ENOMEM;
			parg = mbuf;
			parg = mbuf;
@@ -2849,7 +2849,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,


		err = -EFAULT;
		err = -EFAULT;
		if (_IOC_DIR(cmd) & _IOC_WRITE) {
		if (_IOC_DIR(cmd) & _IOC_WRITE) {
			unsigned int n = size;
			unsigned int n = ioc_size;


			/*
			/*
			 * In some cases, only a few fields are used as input,
			 * In some cases, only a few fields are used as input,
@@ -2870,11 +2870,11 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
				goto out;
				goto out;


			/* zero out anything we don't copy from userspace */
			/* zero out anything we don't copy from userspace */
			if (n < size)
			if (n < ioc_size)
				memset((u8 *)parg + n, 0, size - n);
				memset((u8 *)parg + n, 0, ioc_size - n);
		} else {
		} else {
			/* read-only ioctl */
			/* read-only ioctl */
			memset(parg, 0, size);
			memset(parg, 0, ioc_size);
		}
		}
	}
	}


@@ -2932,7 +2932,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg,
	switch (_IOC_DIR(cmd)) {
	switch (_IOC_DIR(cmd)) {
	case _IOC_READ:
	case _IOC_READ:
	case (_IOC_WRITE | _IOC_READ):
	case (_IOC_WRITE | _IOC_READ):
		if (copy_to_user((void __user *)arg, parg, size))
		if (copy_to_user((void __user *)arg, parg, ioc_size))
			err = -EFAULT;
			err = -EFAULT;
		break;
		break;
	}
	}