diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2016-04-24 09:24:33 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-20 21:33:37 -0400 |
commit | 21916a4a2973ab1684e921689ef8a48a6626ac4c (patch) | |
tree | 19b28389dd9131ed2ba73816b5d6978856a96b83 /drivers/sbus/char | |
parent | 20c698d7791420fb242a0d49b80790fb2d951ace (diff) |
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/sbus/char')
-rw-r--r-- | drivers/sbus/char/openprom.c | 40 |
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) | |||
383 | } | 383 | } |
384 | 384 | ||
385 | /* Copy in a whole string from userspace into kernelspace. */ | 385 | /* Copy in a whole string from userspace into kernelspace. */ |
386 | static int copyin_string(char __user *user, size_t len, char **ptr) | 386 | static char * copyin_string(char __user *user, size_t len) |
387 | { | 387 | { |
388 | char *tmp; | ||
389 | |||
390 | if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0) | 388 | if ((ssize_t)len < 0 || (ssize_t)(len + 1) < 0) |
391 | return -EINVAL; | 389 | return ERR_PTR(-EINVAL); |
392 | |||
393 | tmp = memdup_user_nul(user, len); | ||
394 | if (IS_ERR(tmp)) | ||
395 | return PTR_ERR(tmp); | ||
396 | 390 | ||
397 | *ptr = tmp; | 391 | return memdup_user_nul(user, len); |
398 | |||
399 | return 0; | ||
400 | } | 392 | } |
401 | 393 | ||
402 | /* | 394 | /* |
@@ -415,9 +407,9 @@ static int opiocget(void __user *argp, DATA *data) | |||
415 | 407 | ||
416 | dp = get_node(op.op_nodeid, data); | 408 | dp = get_node(op.op_nodeid, data); |
417 | 409 | ||
418 | err = copyin_string(op.op_name, op.op_namelen, &str); | 410 | str = copyin_string(op.op_name, op.op_namelen); |
419 | if (err) | 411 | if (IS_ERR(str)) |
420 | return err; | 412 | return PTR_ERR(str); |
421 | 413 | ||
422 | pval = of_get_property(dp, str, &len); | 414 | pval = of_get_property(dp, str, &len); |
423 | err = 0; | 415 | err = 0; |
@@ -440,7 +432,7 @@ static int opiocnextprop(void __user *argp, DATA *data) | |||
440 | struct device_node *dp; | 432 | struct device_node *dp; |
441 | struct property *prop; | 433 | struct property *prop; |
442 | char *str; | 434 | char *str; |
443 | int err, len; | 435 | int len; |
444 | 436 | ||
445 | if (copy_from_user(&op, argp, sizeof(op))) | 437 | if (copy_from_user(&op, argp, sizeof(op))) |
446 | return -EFAULT; | 438 | return -EFAULT; |
@@ -449,9 +441,9 @@ static int opiocnextprop(void __user *argp, DATA *data) | |||
449 | if (!dp) | 441 | if (!dp) |
450 | return -EINVAL; | 442 | return -EINVAL; |
451 | 443 | ||
452 | err = copyin_string(op.op_name, op.op_namelen, &str); | 444 | str = copyin_string(op.op_name, op.op_namelen); |
453 | if (err) | 445 | if (IS_ERR(str)) |
454 | return err; | 446 | return PTR_ERR(str); |
455 | 447 | ||
456 | if (str[0] == '\0') { | 448 | if (str[0] == '\0') { |
457 | prop = dp->properties; | 449 | prop = dp->properties; |
@@ -494,14 +486,14 @@ static int opiocset(void __user *argp, DATA *data) | |||
494 | if (!dp) | 486 | if (!dp) |
495 | return -EINVAL; | 487 | return -EINVAL; |
496 | 488 | ||
497 | err = copyin_string(op.op_name, op.op_namelen, &str); | 489 | str = copyin_string(op.op_name, op.op_namelen); |
498 | if (err) | 490 | if (IS_ERR(str)) |
499 | return err; | 491 | return PTR_ERR(str); |
500 | 492 | ||
501 | err = copyin_string(op.op_buf, op.op_buflen, &tmp); | 493 | tmp = copyin_string(op.op_buf, op.op_buflen); |
502 | if (err) { | 494 | if (IS_ERR(tmp)) { |
503 | kfree(str); | 495 | kfree(str); |
504 | return err; | 496 | return PTR_ERR(tmp); |
505 | } | 497 | } |
506 | 498 | ||
507 | err = of_set_property(dp, str, tmp, op.op_buflen); | 499 | err = of_set_property(dp, str, tmp, op.op_buflen); |