kernel_optimize_test/drivers/net/caif
Pavel Skripkin 18ed1789bb net: caif: fix memory leak in ldisc_open
[ Upstream commit 58af3d3d54e87bfc1f936e16c04ade3369d34011 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-06-30 08:47:21 -04:00
..
caif_hsi.c net: caif: Use netif_rx_any_context() 2020-09-29 14:02:53 -07:00
caif_serial.c net: caif: fix memory leak in ldisc_open 2021-06-30 08:47:21 -04:00
caif_virtio.c caif_virtio: Remove redundant initialization of variable err 2020-10-01 18:46:16 -07:00
Kconfig net: caif: Remove unused caif SPI driver 2020-09-29 14:02:53 -07:00
Makefile net: caif: Remove unused caif SPI driver 2020-09-29 14:02:53 -07:00