From patchwork Fri Feb 10 21:11:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 9567525 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51E3D60572 for ; Fri, 10 Feb 2017 21:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37218285D2 for ; Fri, 10 Feb 2017 21:11:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AA4E285D8; Fri, 10 Feb 2017 21:11:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B137285D2 for ; Fri, 10 Feb 2017 21:11:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752312AbdBJVLe (ORCPT ); Fri, 10 Feb 2017 16:11:34 -0500 Received: from mail-it0-f41.google.com ([209.85.214.41]:37294 "EHLO mail-it0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752075AbdBJVLd (ORCPT ); Fri, 10 Feb 2017 16:11:33 -0500 Received: by mail-it0-f41.google.com with SMTP id x75so2559654itb.0 for ; Fri, 10 Feb 2017 13:11:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to :content-transfer-encoding; bh=lWrvKWaQ3egQP9EEZ7oiYAurx6BnSjHScbuHs1s99a0=; b=tHYmCbjdJNDwHTaFA5zdfALINMT73IDrBG7ayFjh2XUZRdDG5TVR9Hl67uZ84Wc6kp F4Ho+nQqGNA1iyx3F+IxiW7miGl/5HHSRHkyBlaQyvqEcxW5p+b5V0evOuL0NfwqOONI Ft8suwEMYJPEoC8BpVgcFuXJ7xe+4+SKAW97AW0pMUn2NTCw0cyWdu2hBL3zkd1zjumt N1lMStJrhNTajmZAJlQRn7RIdmU/6mNlduPqul3kP7hZ/Y1cjKU7Dpr+ixsXtxCjERtm Uhl7ZZEbUUWHAHf0kQ+74fNLelmUoI4PYVOuL525EfY3tf/Hh2EbYRN7MA3IMuJtgIq6 Kh0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to:content-transfer-encoding; bh=lWrvKWaQ3egQP9EEZ7oiYAurx6BnSjHScbuHs1s99a0=; b=DZVovgPVTuupTrAdKRlapUoUa4bVqWJYLjWS5D3rvg5b9h5L9tn6FKsIwwI7p1bZeA zzaE4k9hXGq6vX11+hHR0fgALFccJtg7cZmjYnJwSV56L+8aCcxAsEJYbAVTgnW/h+t9 aoA0dOAYpGdVypIapODtWdKS1/UCN8QKOUzW8WB21tmIsRSX6yCbseL03UuH8eXVFGZD kyTF7XyzFo3xBgoMk4UwI9zhzK8MjmWcchITFLyltvXbNUJU3APg1JaA7bEi5463VJnj WQ/pwrY49K0nJz7xxTW3Ux7RkkAr02eAcqzOpsg0lLnS6vBaKCuDbCXfmN63TxW8tVLS MCng== X-Gm-Message-State: AMke39kIEWu83k5JNY4WYFoFgiv7rqQ35cMM4XG3ql7YqOy5AZurIAmE+FG2IU/Yn4UYoy26Qxh/W7JJesij2Q== X-Received: by 10.36.53.210 with SMTP id k201mr10206181ita.21.1486761092976; Fri, 10 Feb 2017 13:11:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.6.212 with HTTP; Fri, 10 Feb 2017 13:11:32 -0800 (PST) From: Olga Kornievskaia Date: Fri, 10 Feb 2017 16:11:32 -0500 X-Google-Sender-Auth: f1yPMP-wW7dckvcHxiYwInVhziU Message-ID: Subject: question about current code in async op To: linux-nfs Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi folks, As I was writing a new async operation I was looking at other async functions for guidance (i.e.., nfs4_do_close()) and I noticed what looks to me like a memory leak. Am I missing something? I don’t see that “calldata” is freed if rpc_run_task() fails. Thoughts? Here’s what I have to fix it: status = rpc_wait_for_completion_task(task); @@ -6023,6 +6025,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl, .workqueue = nfsiod_workqueue, .flags = RPC_TASK_ASYNC, }; + struct rpc_task *task; nfs4_state_protect(NFS_SERVER(lsp->ls_state->inode)->nfs_client, NFS_SP4_MACH_CRED_CLEANUP, &task_setup_data.rpc_client, &msg); @@ -6042,7 +6045,10 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl, msg.rpc_argp = &data->arg; msg.rpc_resp = &data->res; task_setup_data.callback_data = data; - return rpc_run_task(&task_setup_data); + task = rpc_run_task(&task_setup_data); + if (IS_ERR(task)) + kfree(data); + return task; } static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) @@ -6311,8 +6317,10 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f } else data->arg.new_lock = 1; task = rpc_run_task(&task_setup_data); - if (IS_ERR(task)) + if (IS_ERR(task)) { + kfree(data); return PTR_ERR(task); + } ret = nfs4_wait_for_completion_rpc_task(task); if (ret == 0) { ret = data->rpc_status; --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index d293f06..408cb5b 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -3317,8 +3317,10 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) msg.rpc_resp = &calldata->res; task_setup_data.callback_data = calldata; task = rpc_run_task(&task_setup_data); - if (IS_ERR(task)) + if (IS_ERR(task)) { + kfree(calldata); return PTR_ERR(task); + } status = 0; if (wait)