]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net/wan: fix a double free in x25_asy_open_tty()
authorCong Wang <xiyou.wangcong@gmail.com>
Sat, 29 Dec 2018 21:56:37 +0000 (13:56 -0800)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837257
[ Upstream commit d5c7c745f254c6cb98b3b3f15fe789b8bd770c72 ]

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: 3b780bed3138 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/wan/x25_asy.c

index 74c06a5f586f7d529a0ece30a54d884e75cb903c..4f25c2d8fff065e11e0410aea94bb8b45c4c21ea 100644 (file)
@@ -486,8 +486,10 @@ static int x25_asy_open(struct net_device *dev)
 
        /* Cleanup */
        kfree(sl->xbuff);
+       sl->xbuff = NULL;
 noxbuff:
        kfree(sl->rbuff);
+       sl->rbuff = NULL;
 norbuff:
        return -ENOMEM;
 }