OSDN Git Service

nfsd: Fix svc_xprt refcnt leak when setup callback client failed
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Mon, 25 May 2020 14:15:41 +0000 (22:15 +0800)
committerJ. Bruce Fields <bfields@redhat.com>
Thu, 28 May 2020 22:15:00 +0000 (18:15 -0400)
nfsd4_process_cb_update() invokes svc_xprt_get(), which increases the
refcount of the "c->cn_xprt".

The reference counting issue happens in one exception handling path of
nfsd4_process_cb_update(). When setup callback client failed, the
function forgets to decrease the refcnt increased by svc_xprt_get(),
causing a refcnt leak.

Fix this issue by calling svc_xprt_put() when setup callback client
failed.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4callback.c

index 966ca75..7fbe984 100644 (file)
@@ -1306,6 +1306,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb)
        err = setup_callback_client(clp, &conn, ses);
        if (err) {
                nfsd4_mark_cb_down(clp, err);
+               if (c)
+                       svc_xprt_put(c->cn_xprt);
                return;
        }
 }