Skip to content

Commit f35d129

Browse files
sherllydavem330
authored andcommitted
net/x25: Fix x25_neigh refcnt leak when receiving frame
x25_lapb_receive_frame() invokes x25_get_neigh(), which returns a reference of the specified x25_neigh object to "nb" with increased refcnt. When x25_lapb_receive_frame() returns, local variable "nb" becomes invalid, so the refcount should be decreased to keep refcount balanced. The reference counting issue happens in one path of x25_lapb_receive_frame(). When pskb_may_pull() returns false, the function forgets to decrease the refcnt increased by x25_get_neigh(), causing a refcnt leak. Fix this issue by calling x25_neigh_put() when pskb_may_pull() returns false. Fixes: cb101ed ("x25: Handle undersized/fragmented skbs") Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent b4e0f9a commit f35d129

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/x25/x25_dev.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev,
115115
goto drop;
116116
}
117117

118-
if (!pskb_may_pull(skb, 1))
118+
if (!pskb_may_pull(skb, 1)) {
119+
x25_neigh_put(nb);
119120
return 0;
121+
}
120122

121123
switch (skb->data[0]) {
122124

0 commit comments

Comments
 (0)