Skip to content

Commit d5c7c74

Browse files
congwangdavem330
authored andcommitted
net/wan: fix a double free in x25_asy_open_tty()
When x25_asy_open() fails, it already cleans up by itself, so its caller doesn't need to free the memory again. It seems we still have to call x25_asy_free() to clear the SLF_INUSE bit, so just set these pointers to NULL after kfree(). Reported-and-tested-by: syzbot+5e5e969e525129229052@syzkaller.appspotmail.com Fixes: 3b780be ("x25_asy: Free x25_asy on x25_asy_open() failure.") Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c433570 commit d5c7c74

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/net/wan/x25_asy.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,10 @@ static int x25_asy_open(struct net_device *dev)
485485

486486
/* Cleanup */
487487
kfree(sl->xbuff);
488+
sl->xbuff = NULL;
488489
noxbuff:
489490
kfree(sl->rbuff);
491+
sl->rbuff = NULL;
490492
norbuff:
491493
return -ENOMEM;
492494
}

0 commit comments

Comments
 (0)