From: Dan Carpenter <dan.carpenter@oracle.com>
To: Oleg Drokin <oleg.drokin@intel.com>
Cc: Andreas Dilger <andreas.dilger@intel.com>,
James Simmons <jsimmons@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Liang Zhen <liang.zhen@intel.com>,
Vitaly Fertman <vitaly_fertman@xyratex.com>,
frank zago <fzago@cray.com>,
Sebastien Buisson <sebastien.buisson@bull.net>,
Amir Shehata <amir.shehata@intel.com>,
Niu Yawei <yawei.niu@intel.com>,
lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] staging: lustre/ptlrpc: small leak on allocation failure
Date: Thu, 24 Nov 2016 11:12:04 +0000 [thread overview]
Message-ID: <20161124111204.GH17225@mwanda> (raw)
We should free "desc" before returning NULL.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index ac959ef..8047413 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -128,12 +128,12 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
GET_KIOV(desc) = kcalloc(nfrags, sizeof(*GET_KIOV(desc)),
GFP_NOFS);
if (!GET_KIOV(desc))
- goto out;
+ goto free_desc;
} else {
GET_KVEC(desc) = kcalloc(nfrags, sizeof(*GET_KVEC(desc)),
GFP_NOFS);
if (!GET_KVEC(desc))
- goto out;
+ goto free_desc;
}
spin_lock_init(&desc->bd_lock);
@@ -154,7 +154,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned int nfrags,
LNetInvalidateHandle(&desc->bd_mds[i]);
return desc;
-out:
+free_desc:
+ kfree(desc);
return NULL;
}
next reply other threads:[~2016-11-24 11:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 11:12 Dan Carpenter [this message]
2016-11-25 23:16 ` [lustre-devel] [patch] staging: lustre/ptlrpc: small leak on allocation failure Dilger, Andreas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161124111204.GH17225@mwanda \
--to=dan.carpenter@oracle.com \
--cc=amir.shehata@intel.com \
--cc=andreas.dilger@intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=fzago@cray.com \
--cc=gregkh@linuxfoundation.org \
--cc=jsimmons@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=liang.zhen@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lustre-devel@lists.lustre.org \
--cc=oleg.drokin@intel.com \
--cc=sebastien.buisson@bull.net \
--cc=vitaly_fertman@xyratex.com \
--cc=yawei.niu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).