History

ipv6/sit: fix ipip6_tunnel_get_prl return value

When kcalloc fails, ipip6_tunnel_get_prl() should return -ENOMEM. Move the position of label "out" to return correctly.

katrinzhou committed 4 years ago

Commit adabdd81 parent bce3bb31 file · +3 −5Browse files

Unified · Split

net/ipv6/sit.c+3−5
@@ -323,8 +323,6 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u · 322 unmodified lines
323323 kcalloc(cmax, sizeof(*kp), GFP_KERNEL_ACCOUNT | __GFP_NOWARN) :
324324 NULL;
325325
326− rcu_read_lock();
327−
328326 ca = min(t->prl_count, cmax);
329327
330328 if (!kp) {
@@ -341,7 +339,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u · 10 unmodified lines
341339 }
342340 }
343341
344− c = 0;
342+ rcu_read_lock();
345343 for_each_prl_rcu(t->prl) {
346344 if (c >= cmax)
347345 break;
@@ -353,7 +351,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u · 5 unmodified lines
353351 if (kprl.addr != htonl(INADDR_ANY))
354352 break;
355353 }
356−out:
354+
357355 rcu_read_unlock();
358356
359357 len = sizeof(*kp) * c;
@@ -362,7 +360,7 @@ out: · 2 unmodified lines
362360 ret = -EFAULT;
363361
364362 kfree(kp);
365−
363+out:
366364 return ret;
367365 }
368366