]> git.baikalelectronics.ru Git - kernel.git/commit
net/x25: Fix x25_neigh refcnt leak when receiving frame
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Thu, 23 Apr 2020 05:13:03 +0000 (13:13 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 23 Apr 2020 22:39:39 +0000 (15:39 -0700)
commit7945a7af926fd3e283b1758903694d38bb470fd2
tree6d9a5aae322b7e543997a319914f0a3391cc4fbc
parent5ac45727d67cabf7cc39a686921e2ade4bb6d35a
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: c0cd20953e72 ("x25: Handle undersized/fragmented skbs")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/x25/x25_dev.c