Ver código fonte

decnet: Don't leak entries when rebuilding zone.

As noticed by Ben Hutchings, when we move entries from
one table to another we leak all except the first entry.

Put back the "next" variable removed by commit
9bf9055eb716f85372c41b3fbc51f90bc7653740 ("decnet: Fix set-but-unused
variable.") and use it properly.

Reported-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
David S. Miller 14 anos atrás
pai
commit
a01c1335a3
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3 2
      net/decnet/dn_table.c

+ 3 - 2
net/decnet/dn_table.c

@@ -123,11 +123,12 @@ static inline void dn_rebuild_zone(struct dn_zone *dz,
 				   struct dn_fib_node **old_ht,
 				   struct dn_fib_node **old_ht,
 				   int old_divisor)
 				   int old_divisor)
 {
 {
+	struct dn_fib_node *f, **fp, *next;
 	int i;
 	int i;
-	struct dn_fib_node *f, **fp;
 
 
 	for(i = 0; i < old_divisor; i++) {
 	for(i = 0; i < old_divisor; i++) {
-		for(f = old_ht[i]; f; f = f->fn_next) {
+		for(f = old_ht[i]; f; f = next) {
+			next = f->fn_next;
 			for(fp = dn_chain_p(f->fn_key, dz);
 			for(fp = dn_chain_p(f->fn_key, dz);
 				*fp && dn_key_leq((*fp)->fn_key, f->fn_key);
 				*fp && dn_key_leq((*fp)->fn_key, f->fn_key);
 				fp = &(*fp)->fn_next)
 				fp = &(*fp)->fn_next)