Skip to contentSkip to conversation

bridge: netfilter: fix a memory leak

PATCH Applied Changli Gao 3 participants 3 messages Aug 23, 2010 – Aug 24, 2010

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 bridge: netfilter: fix a memory leak

nf_bridge_alloc() always reset the skb->nf_bridge, so we should always put the old one.

---
v2: Should init tmp->use again because memcpy() overwrite it.

 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_netfilter.c +1 -1
index 2c911c0..5ed00bd 100644
@@ -162,8 +162,8 @@ static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)
 		if (tmp) {
 			memcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));
 			atomic_set(&tmp->use, 1);
-			nf_bridge_put(nf_bridge);
 		}
+		nf_bridge_put(nf_bridge);
 		nf_bridge = tmp;
 	}
 	return nf_bridge;
#1 lore raw

Looks correct to me.

Changli Gao schreef:

Quoted 27 lines

nf_bridge_alloc() always reset the skb->nf_bridge, so we should always put the old one.

---
v2: Should init tmp->use again because memcpy() overwrite it.

 1 file changed, 1 insertion(+), 1 deletion(-)
net/bridge/br_netfilter.c +1 -1
index 2c911c0..5ed00bd 100644
@@ -162,8 +162,8 @@ static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)
 		if (tmp) {
 			memcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));
 			atomic_set(&tmp->use, 1);
-			nf_bridge_put(nf_bridge);
 		}
+		nf_bridge_put(nf_bridge);
 		nf_bridge = tmp;
 	}
 	return nf_bridge;

_______________________________________________
Bridge mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/bridge

Signature · 2 lines
Bart De Schuymer
www.artinalgorithms.be