Commit 21916a4a authored by Sam Ravnborg's avatar Sam Ravnborg Committed by David S. Miller

openprom: fix warning

Fix following warnings:
openprom.c:510:2: warning: 'tmp' may be used uninitialized in this function [-Wmaybe-uninitialized]
openprom.c:503:3: warning: 'str' may be used uninitialized in this function [-Wmaybe-uninitialized]
openprom.c:459:8: warning: 'str' may be used uninitialized in this function [-Wmaybe-uninitialized]
openprom.c:422:7: warning: 'str' may be used uninitialized in this function [-Wmaybe-uninitialized]

Fixed by introducing PTR_ERR etc.
This simplified the code as a nice side effect.
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 20c698d7
...@@ -383,20 +383,12 @@ static struct device_node *get_node(phandle n, DATA *data) ...@@ -383,20 +383,12 @@ static struct device_node *get_node(phandle n, DATA *data)
} }
/* Copy in a whole string from userspace into kernelspace. */ /* 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) if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0)
return -EINVAL; return ERR_PTR(-EINVAL);
tmp = memdup_user_nul(user, len);
if (IS_ERR(tmp))
return PTR_ERR(tmp);
*ptr = tmp; return memdup_user_nul(user, len);
return 0;
} }
/* /*
...@@ -415,9 +407,9 @@ static int opiocget(void __user *argp, DATA *data) ...@@ -415,9 +407,9 @@ static int opiocget(void __user *argp, DATA *data)
dp = get_node(op.op_nodeid, data); dp = get_node(op.op_nodeid, data);
err = copyin_string(op.op_name, op.op_namelen, &str); str = copyin_string(op.op_name, op.op_namelen);
if (err) if (IS_ERR(str))
return err; return PTR_ERR(str);
pval = of_get_property(dp, str, &len); pval = of_get_property(dp, str, &len);
err = 0; err = 0;
...@@ -440,7 +432,7 @@ static int opiocnextprop(void __user *argp, DATA *data) ...@@ -440,7 +432,7 @@ static int opiocnextprop(void __user *argp, DATA *data)
struct device_node *dp; struct device_node *dp;
struct property *prop; struct property *prop;
char *str; char *str;
int err, len; int len;
if (copy_from_user(&op, argp, sizeof(op))) if (copy_from_user(&op, argp, sizeof(op)))
return -EFAULT; return -EFAULT;
...@@ -449,9 +441,9 @@ static int opiocnextprop(void __user *argp, DATA *data) ...@@ -449,9 +441,9 @@ static int opiocnextprop(void __user *argp, DATA *data)
if (!dp) if (!dp)
return -EINVAL; return -EINVAL;
err = copyin_string(op.op_name, op.op_namelen, &str); str = copyin_string(op.op_name, op.op_namelen);
if (err) if (IS_ERR(str))
return err; return PTR_ERR(str);
if (str[0] == '\0') { if (str[0] == '\0') {
prop = dp->properties; prop = dp->properties;
...@@ -494,14 +486,14 @@ static int opiocset(void __user *argp, DATA *data) ...@@ -494,14 +486,14 @@ static int opiocset(void __user *argp, DATA *data)
if (!dp) if (!dp)
return -EINVAL; return -EINVAL;
err = copyin_string(op.op_name, op.op_namelen, &str); str = copyin_string(op.op_name, op.op_namelen);
if (err) if (IS_ERR(str))
return err; return PTR_ERR(str);
err = copyin_string(op.op_buf, op.op_buflen, &tmp); tmp = copyin_string(op.op_buf, op.op_buflen);
if (err) { if (IS_ERR(tmp)) {
kfree(str); kfree(str);
return err; return PTR_ERR(tmp);
} }
err = of_set_property(dp, str, tmp, op.op_buflen); err = of_set_property(dp, str, tmp, op.op_buflen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment