@@ -3275,25 +3275,31 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
3275
3275
3276
3276
err_nh = NULL ;
3277
3277
list_for_each_entry (nh , & rt6_nh_list , next ) {
3278
+ dst_hold (& nh -> rt6_info -> dst );
3278
3279
err = __ip6_ins_rt (nh -> rt6_info , info , & nh -> mxc , extack );
3279
3280
3280
3281
if (!err ) {
3281
- /* save reference to last route successfully inserted */
3282
- rt_last = nh -> rt6_info ;
3283
-
3284
- /* save reference to first route for notification */
3285
- if (!rt_notif )
3286
- rt_notif = nh -> rt6_info ;
3287
3282
}
3288
3283
3289
- /* nh->rt6_info is used or freed at this point, reset to NULL*/
3290
- nh -> rt6_info = NULL ;
3291
3284
if (err ) {
3292
3285
if (replace && nhn )
3293
3286
ip6_print_replace_route_err (& rt6_nh_list );
3294
3287
err_nh = nh ;
3295
3288
goto add_errout ;
3296
3289
}
3290
+ /* save reference to last route successfully inserted */
3291
+ rt_last = nh -> rt6_info ;
3292
+
3293
+ /* save reference to first route for notification */
3294
+ if (!rt_notif )
3295
+ rt_notif = nh -> rt6_info ;
3296
+
3297
+ /* save reference to last route successfully inserted */
3298
+ rt_last = nh -> rt6_info ;
3299
+
3300
+ /* save reference to first route for notification */
3301
+ if (!rt_notif )
3302
+ rt_notif = nh -> rt6_info ;
3297
3303
3298
3304
/* Because each route is added like a single route we remove
3299
3305
* these flags after the first nexthop: if there is a collision,
@@ -3331,8 +3337,7 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
3331
3337
3332
3338
cleanup :
3333
3339
list_for_each_entry_safe (nh , nh_safe , & rt6_nh_list , next ) {
3334
- if (nh -> rt6_info )
3335
- dst_release_immediate (& nh -> rt6_info -> dst );
3340
+ dst_release_immediate (& nh -> rt6_info -> dst );
3336
3341
kfree (nh -> mxc .mx );
3337
3342
list_del (& nh -> next );
3338
3343
kfree (nh );
0 commit comments