]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lapb: fixed leak of control-blocks.
authorJeremy Sowden <jeremy@azazel.net>
Sun, 16 Jun 2019 15:54:37 +0000 (16:54 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jun 2019 03:44:20 +0000 (20:44 -0700)
lapb_register calls lapb_create_cb, which initializes the control-
block's ref-count to one, and __lapb_insert_cb, which increments it when
adding the new block to the list of blocks.

lapb_unregister calls __lapb_remove_cb, which decrements the ref-count
when removing control-block from the list of blocks, and calls lapb_put
itself to decrement the ref-count before returning.

However, lapb_unregister also calls __lapb_devtostruct to look up the
right control-block for the given net_device, and __lapb_devtostruct
also bumps the ref-count, which means that when lapb_unregister returns
the ref-count is still 1 and the control-block is leaked.

Call lapb_put after __lapb_devtostruct to fix leak.

Reported-by: syzbot+afb980676c836b4a0afa@syzkaller.appspotmail.com
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/lapb/lapb_iface.c

index 03f0cd872dcec1596b413e41df89f3ee256bf153..5d2d1f746b9176b452487657a2dc164911411cf9 100644 (file)
@@ -177,6 +177,7 @@ int lapb_unregister(struct net_device *dev)
        lapb = __lapb_devtostruct(dev);
        if (!lapb)
                goto out;
+       lapb_put(lapb);
 
        lapb_stop_t1timer(lapb);
        lapb_stop_t2timer(lapb);