diff options
Diffstat (limited to 'net/ipv4/devinet.c')
-rw-r--r-- | net/ipv4/devinet.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 5ab5acc17e44..3376d635c847 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -492,39 +492,34 @@ static struct in_ifaddr *rtm_to_ifaddr(struct nlmsghdr *nlh) | |||
492 | struct ifaddrmsg *ifm; | 492 | struct ifaddrmsg *ifm; |
493 | struct net_device *dev; | 493 | struct net_device *dev; |
494 | struct in_device *in_dev; | 494 | struct in_device *in_dev; |
495 | int err = -EINVAL; | 495 | int err; |
496 | 496 | ||
497 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy); | 497 | err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv4_policy); |
498 | if (err < 0) | 498 | if (err < 0) |
499 | goto errout; | 499 | goto errout; |
500 | 500 | ||
501 | ifm = nlmsg_data(nlh); | 501 | ifm = nlmsg_data(nlh); |
502 | if (ifm->ifa_prefixlen > 32 || tb[IFA_LOCAL] == NULL) { | 502 | err = -EINVAL; |
503 | err = -EINVAL; | 503 | if (ifm->ifa_prefixlen > 32 || tb[IFA_LOCAL] == NULL) |
504 | goto errout; | 504 | goto errout; |
505 | } | ||
506 | 505 | ||
507 | dev = __dev_get_by_index(&init_net, ifm->ifa_index); | 506 | dev = __dev_get_by_index(&init_net, ifm->ifa_index); |
508 | if (dev == NULL) { | 507 | err = -ENODEV; |
509 | err = -ENODEV; | 508 | if (dev == NULL) |
510 | goto errout; | 509 | goto errout; |
511 | } | ||
512 | 510 | ||
513 | in_dev = __in_dev_get_rtnl(dev); | 511 | in_dev = __in_dev_get_rtnl(dev); |
514 | if (in_dev == NULL) { | 512 | err = -ENOBUFS; |
515 | err = -ENOBUFS; | 513 | if (in_dev == NULL) |
516 | goto errout; | 514 | goto errout; |
517 | } | ||
518 | 515 | ||
519 | ifa = inet_alloc_ifa(); | 516 | ifa = inet_alloc_ifa(); |
520 | if (ifa == NULL) { | 517 | if (ifa == NULL) |
521 | /* | 518 | /* |
522 | * A potential indev allocation can be left alive, it stays | 519 | * A potential indev allocation can be left alive, it stays |
523 | * assigned to its device and is destroy with it. | 520 | * assigned to its device and is destroy with it. |
524 | */ | 521 | */ |
525 | err = -ENOBUFS; | ||
526 | goto errout; | 522 | goto errout; |
527 | } | ||
528 | 523 | ||
529 | ipv4_devconf_setall(in_dev); | 524 | ipv4_devconf_setall(in_dev); |
530 | in_dev_hold(in_dev); | 525 | in_dev_hold(in_dev); |