Skip to content

Commit 5a9348b

Browse files
Dan Carpenterdavem330
authored andcommitted
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 <[email protected]> Acked-by: Roopa Prabhu <[email protected]> Acked-by: Robert Shearman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 02b5242 commit 5a9348b

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

net/mpls/af_mpls.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,23 +338,21 @@ static unsigned find_free_label(struct net *net)
338338
#if IS_ENABLED(CONFIG_INET)
339339
static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
340340
{
341-
struct net_device *dev = NULL;
341+
struct net_device *dev;
342342
struct rtable *rt;
343343
struct in_addr daddr;
344344

345345
memcpy(&daddr, addr, sizeof(struct in_addr));
346346
rt = ip_route_output(net, daddr.s_addr, 0, 0, 0);
347347
if (IS_ERR(rt))
348-
goto errout;
348+
return ERR_CAST(rt);
349349

350350
dev = rt->dst.dev;
351351
dev_hold(dev);
352352

353353
ip_rt_put(rt);
354354

355355
return dev;
356-
errout:
357-
return ERR_PTR(-ENODEV);
358356
}
359357
#else
360358
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)
366364
#if IS_ENABLED(CONFIG_IPV6)
367365
static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)
368366
{
369-
struct net_device *dev = NULL;
367+
struct net_device *dev;
370368
struct dst_entry *dst;
371369
struct flowi6 fl6;
372370
int err;
@@ -378,16 +376,13 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)
378376
memcpy(&fl6.daddr, addr, sizeof(struct in6_addr));
379377
err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6);
380378
if (err)
381-
goto errout;
379+
return ERR_PTR(err);
382380

383381
dev = dst->dev;
384382
dev_hold(dev);
385383
dst_release(dst);
386384

387385
return dev;
388-
389-
errout:
390-
return ERR_PTR(err);
391386
}
392387
#else
393388
static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)

0 commit comments

Comments
 (0)