]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net/sunrpc: fix reference count leaks in rpc_sysfs_xprt_state_change
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Thu, 9 Sep 2021 04:32:38 +0000 (12:32 +0800)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Thu, 13 Jan 2022 14:36:58 +0000 (09:36 -0500)
The refcount leak issues take place in an error handling path. When the
3rd argument buf doesn't match with "offline", "online" or "remove", the
function simply returns -EINVAL and forgets to decrease the reference
count of a rpc_xprt object and a rpc_xprt_switch object increased by
rpc_sysfs_xprt_kobj_get_xprt() and
rpc_sysfs_xprt_kobj_get_xprt_switch(), causing reference count leaks of
both unused objects.

Fix this issue by jumping to the error handling path labelled with
out_put when buf matches none of "offline", "online" or "remove".

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/sysfs.c

index b1aea3419218d76318f619915204f8db323aaefb..49fd0339dc59cb4aef427fe206de15ae2b738e84 100644 (file)
@@ -295,8 +295,10 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj,
                online = 1;
        else if (!strncmp(buf, "remove", 6))
                remove = 1;
-       else
-               return -EINVAL;
+       else {
+               count = -EINVAL;
+               goto out_put;
+       }
 
        if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) {
                count = -EINTR;