diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2015-08-04 03:44:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-08-07 00:56:55 -0400 |
commit | 5a9348b54d396c0b8bb877abcb107293034a87de (patch) | |
tree | 4e5da9caa8ad15e4765690ebce4be1bf1b8c0726 /net/mpls | |
parent | 02b52428475672a241365910949deb6fe95d043c (diff) |
mpls: small cleanup in inet/inet6_fib_lookup_dev()
We recently changed this code from returning NULL to returning ERR_PTR.
There are some left over NULL assignments which we can remove. We can
preserve the error code from ip_route_output() instead of always
returning -ENODEV. Also these functions use a mix of gotos and direct
returns. There is no cleanup necessary so I changed the gotos to
direct returns.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: Robert Shearman <rshearma@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mpls')
-rw-r--r-- | net/mpls/af_mpls.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index b6b9a6c4e784..d93c0301ad23 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c | |||
@@ -338,14 +338,14 @@ static unsigned find_free_label(struct net *net) | |||
338 | #if IS_ENABLED(CONFIG_INET) | 338 | #if IS_ENABLED(CONFIG_INET) |
339 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | 339 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) |
340 | { | 340 | { |
341 | struct net_device *dev = NULL; | 341 | struct net_device *dev; |
342 | struct rtable *rt; | 342 | struct rtable *rt; |
343 | struct in_addr daddr; | 343 | struct in_addr daddr; |
344 | 344 | ||
345 | memcpy(&daddr, addr, sizeof(struct in_addr)); | 345 | memcpy(&daddr, addr, sizeof(struct in_addr)); |
346 | rt = ip_route_output(net, daddr.s_addr, 0, 0, 0); | 346 | rt = ip_route_output(net, daddr.s_addr, 0, 0, 0); |
347 | if (IS_ERR(rt)) | 347 | if (IS_ERR(rt)) |
348 | goto errout; | 348 | return ERR_CAST(rt); |
349 | 349 | ||
350 | dev = rt->dst.dev; | 350 | dev = rt->dst.dev; |
351 | dev_hold(dev); | 351 | dev_hold(dev); |
@@ -353,8 +353,6 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | |||
353 | ip_rt_put(rt); | 353 | ip_rt_put(rt); |
354 | 354 | ||
355 | return dev; | 355 | return dev; |
356 | errout: | ||
357 | return ERR_PTR(-ENODEV); | ||
358 | } | 356 | } |
359 | #else | 357 | #else |
360 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | 358 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) |
@@ -366,7 +364,7 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | |||
366 | #if IS_ENABLED(CONFIG_IPV6) | 364 | #if IS_ENABLED(CONFIG_IPV6) |
367 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) | 365 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) |
368 | { | 366 | { |
369 | struct net_device *dev = NULL; | 367 | struct net_device *dev; |
370 | struct dst_entry *dst; | 368 | struct dst_entry *dst; |
371 | struct flowi6 fl6; | 369 | struct flowi6 fl6; |
372 | int err; | 370 | int err; |
@@ -378,16 +376,13 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) | |||
378 | memcpy(&fl6.daddr, addr, sizeof(struct in6_addr)); | 376 | memcpy(&fl6.daddr, addr, sizeof(struct in6_addr)); |
379 | err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6); | 377 | err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6); |
380 | if (err) | 378 | if (err) |
381 | goto errout; | 379 | return ERR_PTR(err); |
382 | 380 | ||
383 | dev = dst->dev; | 381 | dev = dst->dev; |
384 | dev_hold(dev); | 382 | dev_hold(dev); |
385 | dst_release(dst); | 383 | dst_release(dst); |
386 | 384 | ||
387 | return dev; | 385 | return dev; |
388 | |||
389 | errout: | ||
390 | return ERR_PTR(err); | ||
391 | } | 386 | } |
392 | #else | 387 | #else |
393 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) | 388 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) |