netlink: put module reference if dump start fails
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 21 Feb 2018 03:41:59 +0000 (04:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 11 Mar 2018 15:21:31 +0000 (16:21 +0100)
commite7b12efd7da92455f59f23dde01e80aaa8cdfcfa
treea5ce9f2d3573bbaf5dcc4b8e99874204fc3cfecf
parenteb2593fbd643f68a557b62141106788242183954
netlink: put module reference if dump start fails

commit b87b6194be631c94785fe93398651e804ed43e28 upstream.

Before, if cb->start() failed, the module reference would never be put,
because cb->cb_running is intentionally false at this point. Users are
generally annoyed by this because they can no longer unload modules that
leak references. Also, it may be possible to tediously wrap a reference
counter back to zero, especially since module.c still uses atomic_inc
instead of refcount_inc.

This patch expands the error path to simply call module_put if
cb->start() fails.

Fixes: 41c87425a1ac ("netlink: do not set cb_running if dump's start() errs")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/netlink/af_netlink.c