From: Jason A. Donenfeld Date: Wed, 21 Feb 2018 03:41:59 +0000 (+0100) Subject: netlink: put module reference if dump start fails X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=eec434c573e78c1190a812cb48a8b16c254541ea;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git netlink: put module reference if dump start fails [ Upstream commit b87b6194be631c94785fe93398651e804ed43e28 ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 533fd0503ba0..9219bc134109 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -2276,7 +2276,7 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, if (cb->start) { ret = cb->start(cb); if (ret) - goto error_unlock; + goto error_put; } nlk->cb_running = true; @@ -2296,6 +2296,8 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, */ return -EINTR; +error_put: + module_put(control->module); error_unlock: sock_put(sk); mutex_unlock(nlk->cb_mutex);