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

Commit 9ea2b82e authored by H. Peter Anvin's avatar H. Peter Anvin
Browse files

x86: cpuid: correct return value on partial operations



Return the correct return value when the CPUID driver partially
completes a request (we should return the number of bytes actually
read or written, instead of the error code.)

Signed-off-by: default avatarH. Peter Anvin <hpa@zytor.com>
parent 85f1cb60
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -89,7 +89,8 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
	struct cpuid_regs cmd;
	int cpu = iminor(file->f_path.dentry->d_inode);
	u64 pos = *ppos;
	int err;
	ssize_t bytes = 0;
	int err = 0;

	if (count % 16)
		return -EINVAL;	/* Invalid chunk size */
@@ -99,14 +100,17 @@ static ssize_t cpuid_read(struct file *file, char __user *buf,
		cmd.ecx = pos >> 32;
		err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1);
		if (err)
			return err;
		if (copy_to_user(tmp, &cmd, 16))
			return -EFAULT;
			break;
		if (copy_to_user(tmp, &cmd, 16)) {
			err = -EFAULT;
			break;
		}
		tmp += 16;
		bytes += 16;
		*ppos = ++pos;
	}

	return tmp - buf;
	return bytes ? bytes : err;
}

static int cpuid_open(struct inode *inode, struct file *file)