• Marcel Holtmann's avatar
    [IRDA]: Fix rfcomm use-after-free · 09c7d829
    Marcel Holtmann authored
    Adrian Bunk wrote:
    > Commit 8de0a154 added the following
    > use-after-free in net/bluetooth/rfcomm/tty.c:
    >
    > <--  snip  -->
    >
    > ...
    > static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
    > {
    > ...
    >         if (IS_ERR(dev->tty_dev)) {
    >                 list_del(&dev->list);
    >                 kfree(dev);
    >                 return PTR_ERR(dev->tty_dev);
    >         }
    > ...
    >
    > <--  snip  -->
    >
    > Spotted by the Coverity checker.
    
    really good catch. I fully overlooked that one. The attached patch
    should fix it.
    Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    09c7d829
tty.c 24.9 KB