@@ -5355,26 +5355,20 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
53555355 err_nh = NULL ;
53565356 list_for_each_entry (nh , & rt6_nh_list , next ) {
53575357 err = __ip6_ins_rt (nh -> fib6_info , info , extack );
5358- fib6_info_release (nh -> fib6_info );
5359-
5360- if (!err ) {
5361- /* save reference to last route successfully inserted */
5362- rt_last = nh -> fib6_info ;
5363-
5364- /* save reference to first route for notification */
5365- if (!rt_notif )
5366- rt_notif = nh -> fib6_info ;
5367- }
53685358
5369- /* nh->fib6_info is used or freed at this point, reset to NULL*/
5370- nh -> fib6_info = NULL ;
53715359 if (err ) {
53725360 if (replace && nhn )
53735361 NL_SET_ERR_MSG_MOD (extack ,
53745362 "multipath route replace failed (check consistency of installed routes)" );
53755363 err_nh = nh ;
53765364 goto add_errout ;
53775365 }
5366+ /* save reference to last route successfully inserted */
5367+ rt_last = nh -> fib6_info ;
5368+
5369+ /* save reference to first route for notification */
5370+ if (!rt_notif )
5371+ rt_notif = nh -> fib6_info ;
53785372
53795373 /* Because each route is added like a single route we remove
53805374 * these flags after the first nexthop: if there is a collision,
@@ -5435,8 +5429,7 @@ static int ip6_route_multipath_add(struct fib6_config *cfg,
54355429
54365430cleanup :
54375431 list_for_each_entry_safe (nh , nh_safe , & rt6_nh_list , next ) {
5438- if (nh -> fib6_info )
5439- fib6_info_release (nh -> fib6_info );
5432+ fib6_info_release (nh -> fib6_info );
54405433 list_del (& nh -> next );
54415434 kfree (nh );
54425435 }
0 commit comments