When kcalloc fails, ipip6_tunnel_get_prl() should return -ENOMEM. Move the position of label "out" to return correctly.
Unified · Split
| @@ -323,8 +323,6 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u · 322 unmodified lines | |||
| 323 | kcalloc(cmax, sizeof(*kp), GFP_KERNEL_ACCOUNT | __GFP_NOWARN) : | 323 | kcalloc(cmax, sizeof(*kp), GFP_KERNEL_ACCOUNT | __GFP_NOWARN) : |
| 324 | NULL; | 324 | NULL; |
| 325 | 325 | ||
| 326 | rcu_read_lock(); | ||
| 327 | |||
| 328 | ca = min(t->prl_count, cmax); | 326 | ca = min(t->prl_count, cmax); |
| 329 | 327 | ||
| 330 | if (!kp) { | 328 | if (!kp) { |
| @@ -341,7 +339,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u · 10 unmodified lines | |||
| 341 | } | 339 | } |
| 342 | } | 340 | } |
| 343 | 341 | ||
| 344 | c = 0; | 342 | rcu_read_lock(); |
| 345 | for_each_prl_rcu(t->prl) { | 343 | for_each_prl_rcu(t->prl) { |
| 346 | if (c >= cmax) | 344 | if (c >= cmax) |
| 347 | break; | 345 | break; |
| @@ -353,7 +351,7 @@ static int ipip6_tunnel_get_prl(struct net_device *dev, struct ip_tunnel_prl __u · 5 unmodified lines | |||
| 353 | if (kprl.addr != htonl(INADDR_ANY)) | 351 | if (kprl.addr != htonl(INADDR_ANY)) |
| 354 | break; | 352 | break; |
| 355 | } | 353 | } |
| 356 | out: | 354 | |
| 357 | rcu_read_unlock(); | 355 | rcu_read_unlock(); |
| 358 | 356 | ||
| 359 | len = sizeof(*kp) * c; | 357 | len = sizeof(*kp) * c; |
| @@ -362,7 +360,7 @@ out: · 2 unmodified lines | |||
| 362 | ret = -EFAULT; | 360 | ret = -EFAULT; |
| 363 | 361 | ||
| 364 | kfree(kp); | 362 | kfree(kp); |
| 365 | 363 | out: | |
| 366 | return ret; | 364 | return ret; |
| 367 | } | 365 | } |
| 368 | 366 | ||