Skip to content

Commit 6979ab4

Browse files
congwanggregkh
authored andcommitted
netrom: fix a memory leak in nr_rx_frame()
[ Upstream commit c8c8218 ] When the skb is associated with a new sock, just assigning it to skb->sk is not sufficient, we have to set its destructor to free the sock properly too. Reported-by: syzbot+d6636a36d3c34bd88938@syzkaller.appspotmail.com Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6334936 commit 6979ab4

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

net/netrom/af_netrom.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
870870
unsigned short frametype, flags, window, timeout;
871871
int ret;
872872

873-
skb->sk = NULL; /* Initially we don't know who it's for */
873+
skb_orphan(skb);
874874

875875
/*
876876
* skb->data points to the netrom frame start
@@ -969,6 +969,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
969969
window = skb->data[20];
970970

971971
skb->sk = make;
972+
skb->destructor = sock_efree;
972973
make->sk_state = TCP_ESTABLISHED;
973974

974975
/* Fill in his circuit details */

0 commit comments

Comments
 (0)