Skip to content

Commit

Permalink
lapb: fixed leak of control-blocks.
Browse files Browse the repository at this point in the history
[ Upstream commit 6be8e29 ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
a3a3el authored and gregkh committed Jun 22, 2019
1 parent 3cc4e63 commit f0662be
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/lapb/lapb_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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);
Expand Down

0 comments on commit f0662be

Please sign in to comment.