summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2016-04-24 15:24:33 +0200
committerDavid S. Miller <davem@davemloft.net>2016-05-20 18:33:37 -0700
commit21916a4a2973ab1684e921689ef8a48a6626ac4c (patch)
tree19b28389dd9131ed2ba73816b5d6978856a96b83 /drivers
parent20c698d7791420fb242a0d49b80790fb2d951ace (diff)
downloadlinux-21916a4a2973ab1684e921689ef8a48a6626ac4c.tar.bz2
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: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/sbus/char/openprom.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c
index e077ebd89319..4612691c6619 100644
--- a/drivers/sbus/char/openprom.c
+++ b/drivers/sbus/char/openprom.c
@@ -383,20 +383,12 @@ static struct device_node *get_node(phandle n, DATA *data)
}
/* 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);
}
/*
@@ -415,9 +407,9 @@ static int opiocget(void __user *argp, DATA *data)
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;
@@ -440,7 +432,7 @@ static int opiocnextprop(void __user *argp, DATA *data)
struct device_node *dp;
struct property *prop;
char *str;
- int err, len;
+ int len;
if (copy_from_user(&op, argp, sizeof(op)))
return -EFAULT;
@@ -449,9 +441,9 @@ static int opiocnextprop(void __user *argp, DATA *data)
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;
@@ -494,14 +486,14 @@ static int opiocset(void __user *argp, DATA *data)
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);