• Xiyu Yang's avatar
    net/x25: Fix x25_neigh refcnt leak when receiving frame · f35d1297
    Xiyu Yang authored
    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: cb101ed2 ("x25: Handle undersized/fragmented skbs")
    Signed-off-by: default avatarXiyu Yang <xiyuyang19@fudan.edu.cn>
    Signed-off-by: default avatarXin Tan <tanxin.ctf@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    f35d1297
x25_dev.c 4.22 KB