diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 12a2cea9d606a033489f65a4950be572add4d53d..64f0fa0be370e20ed151004daf4c0cd0dd36d1cb 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -341,12 +341,13 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, { struct in_ifaddr *promote = NULL; struct in_ifaddr *ifa, *ifa1 = *ifap; - struct in_ifaddr *last_prim = in_dev->ifa_list; + struct in_ifaddr **last_prim; struct in_ifaddr *prev_prom = NULL; int do_promote = IN_DEV_PROMOTE_SECONDARIES(in_dev); ASSERT_RTNL(); + last_prim = ifap; if (in_dev->dead) goto no_promotions; @@ -360,7 +361,7 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, while ((ifa = *ifap1) != NULL) { if (!(ifa->ifa_flags & IFA_F_SECONDARY) && ifa1->ifa_scope <= ifa->ifa_scope) - last_prim = ifa; + last_prim = &ifa->ifa_next; if (!(ifa->ifa_flags & IFA_F_SECONDARY) || ifa1->ifa_mask != ifa->ifa_mask || @@ -420,8 +421,8 @@ static void __inet_del_ifa(struct in_device *in_dev, struct in_ifaddr **ifap, if (prev_prom) { prev_prom->ifa_next = promote->ifa_next; - promote->ifa_next = last_prim->ifa_next; - last_prim->ifa_next = promote; + promote->ifa_next = *last_prim; + *last_prim = promote; } promote->ifa_flags &= ~IFA_F_SECONDARY;