}
/* Copy in a whole string from userspace into kernelspace. */
-static int copyin_string(char __user *user, size_t len, char **ptr)
+static char * copyin_string(char __user *user, size_t len)
{
- char *tmp;
-
if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0)
- return -EINVAL;
-
- tmp = memdup_user_nul(user, len);
- if (IS_ERR(tmp))
- return PTR_ERR(tmp);
+ return ERR_PTR(-EINVAL);
- *ptr = tmp;
-
- return 0;
+ return memdup_user_nul(user, len);
}
/*
dp = get_node(op.op_nodeid, data);
- err = copyin_string(op.op_name, op.op_namelen, &str);
- if (err)
- return err;
+ str = copyin_string(op.op_name, op.op_namelen);
+ if (IS_ERR(str))
+ return PTR_ERR(str);
pval = of_get_property(dp, str, &len);
err = 0;
struct device_node *dp;
struct property *prop;
char *str;
- int err, len;
+ int len;
if (copy_from_user(&op, argp, sizeof(op)))
return -EFAULT;
if (!dp)
return -EINVAL;
- err = copyin_string(op.op_name, op.op_namelen, &str);
- if (err)
- return err;
+ str = copyin_string(op.op_name, op.op_namelen);
+ if (IS_ERR(str))
+ return PTR_ERR(str);
if (str[0] == '\0') {
prop = dp->properties;
if (!dp)
return -EINVAL;
- err = copyin_string(op.op_name, op.op_namelen, &str);
- if (err)
- return err;
+ str = copyin_string(op.op_name, op.op_namelen);
+ if (IS_ERR(str))
+ return PTR_ERR(str);
- err = copyin_string(op.op_buf, op.op_buflen, &tmp);
- if (err) {
+ tmp = copyin_string(op.op_buf, op.op_buflen);
+ if (IS_ERR(tmp)) {
kfree(str);
- return err;
+ return PTR_ERR(tmp);
}
err = of_set_property(dp, str, tmp, op.op_buflen);