提交 b87b6194 编写于 作者: J Jason A. Donenfeld 提交者: David S. Miller

netlink: put module reference if dump start fails

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: 41c87425 ("netlink: do not set cb_running if dump's start() errs")
Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 cfd092f2
...@@ -2308,7 +2308,7 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, ...@@ -2308,7 +2308,7 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
if (cb->start) { if (cb->start) {
ret = cb->start(cb); ret = cb->start(cb);
if (ret) if (ret)
goto error_unlock; goto error_put;
} }
nlk->cb_running = true; nlk->cb_running = true;
...@@ -2328,6 +2328,8 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb, ...@@ -2328,6 +2328,8 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
*/ */
return -EINTR; return -EINTR;
error_put:
module_put(control->module);
error_unlock: error_unlock:
sock_put(sk); sock_put(sk);
mutex_unlock(nlk->cb_mutex); mutex_unlock(nlk->cb_mutex);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册