diff options
author | Pavel Skripkin <paskripkin@gmail.com> | 2021-06-12 17:51:22 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-06-14 12:28:16 -0700 |
commit | 58af3d3d54e87bfc1f936e16c04ade3369d34011 (patch) | |
tree | 32cb8fc66912fa15130ecd83b6909f8fc815ffd3 /drivers | |
parent | 09427c1915f754ebe7d3d8e54e79bbee48afe916 (diff) | |
download | linux-stable-58af3d3d54e87bfc1f936e16c04ade3369d34011.tar.gz linux-stable-58af3d3d54e87bfc1f936e16c04ade3369d34011.tar.bz2 linux-stable-58af3d3d54e87bfc1f936e16c04ade3369d34011.zip |
net: caif: fix memory leak in ldisc_open
Syzbot reported memory leak in tty_init_dev().
The problem was in unputted tty in ldisc_open()
static int ldisc_open(struct tty_struct *tty)
{
...
ser->tty = tty_kref_get(tty);
...
result = register_netdevice(dev);
if (result) {
rtnl_unlock();
free_netdev(dev);
return -ENODEV;
}
...
}
Ser pointer is netdev private_data, so after free_netdev()
this pointer goes away with unputted tty reference. So, fix
it by adding tty_kref_put() before freeing netdev.
Reported-and-tested-by: syzbot+f303e045423e617d2cad@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/caif/caif_serial.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c index d17482395a4d..4ffbfd534f18 100644 --- a/drivers/net/caif/caif_serial.c +++ b/drivers/net/caif/caif_serial.c @@ -350,6 +350,7 @@ static int ldisc_open(struct tty_struct *tty) rtnl_lock(); result = register_netdevice(dev); if (result) { + tty_kref_put(tty); rtnl_unlock(); free_netdev(dev); return -ENODEV; |