Patch "net: caif: fix memory leak in ldisc_open" has been added to the 5.12-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: caif: fix memory leak in ldisc_open

to the 5.12-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-caif-fix-memory-leak-in-ldisc_open.patch
and it can be found in the queue-5.12 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 0d59c91dae8f8567fcac85f4a7897497e0c1ff20
Author: Pavel Skripkin <paskripkin@xxxxxxxxx>
Date:   Sat Jun 12 17:51:22 2021 +0300

    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@xxxxxxxxxxxxxxxxxxxxxxxxx
    Signed-off-by: Pavel Skripkin <paskripkin@xxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/caif/caif_serial.c b/drivers/net/caif/caif_serial.c
index 9f30748da4ab..8c38f224becb 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;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux