]> git.baikalelectronics.ru Git - kernel.git/commit
afs: Fix leak in afs_lookup_cell_rcu()
authorDavid Howells <dhowells@redhat.com>
Thu, 22 Aug 2019 12:28:43 +0000 (13:28 +0100)
committerDavid Howells <dhowells@redhat.com>
Thu, 22 Aug 2019 12:33:26 +0000 (13:33 +0100)
commit60fb11b0b7d335d9f4d2fd7b29f4affd6e1672ae
tree789dd4ce9ffac3d52183dcd1df3b1dc8260549a0
parent75eaf80f84ebc7588c50189fc3b72bcd0f66e5fc
afs: Fix leak in afs_lookup_cell_rcu()

Fix a leak on the cell refcount in afs_lookup_cell_rcu() due to
non-clearance of the default error in the case a NULL cell name is passed
and the workstation default cell is used.

Also put a bit at the end to make sure we don't leak a cell ref if we're
going to be returning an error.

This leak results in an assertion like the following when the kafs module is
unloaded:

AFS: Assertion failed
2 == 1 is false
0x2 == 0x1 is false
------------[ cut here ]------------
kernel BUG at fs/afs/cell.c:770!
...
RIP: 0010:afs_manage_cells+0x220/0x42f [kafs]
...
 process_one_work+0x4c2/0x82c
 ? pool_mayday_timeout+0x1e1/0x1e1
 ? do_raw_spin_lock+0x134/0x175
 worker_thread+0x336/0x4a6
 ? rescuer_thread+0x4af/0x4af
 kthread+0x1de/0x1ee
 ? kthread_park+0xd4/0xd4
 ret_from_fork+0x24/0x30

Fixes: b7ec0ed2b7a0 ("afs: Overhaul cell database management")
Signed-off-by: David Howells <dhowells@redhat.com>
fs/afs/cell.c