summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server
diff options
context:
space:
mode:
authorSantosh Kumar Pradhan <spradhan@redhat.com>2014-01-29 17:09:55 +0530
committerVijay Bellur <vbellur@redhat.com>2014-02-11 21:06:53 -0800
commit99c84c250501a676f73c0dd7e9b842f8c95b1f98 (patch)
tree47a1f05fae1ae6b5915c98b3d756c0ca7ee634ae /xlators/nfs/server
parent408d50a64b7b3a9d6a4899060baa423ff126cc5f (diff)
gNFS: Coverity fix for possible memory leak
In nfs_gfid_dict(), if dict_new() fails, the control goes to out: block and dyngfid resource (dynamically allocated by GF_CALLOC()) is leaked. Add a validation for memory returned by GF_CALLOC() Drop unnecessary "goto" statements Coverity CID: 1124764 Change-Id: Idda7923cc1c32260b3353f7a9141aa1cf43e4fe1 BUG: 789278 Signed-off-by: Santosh Kumar Pradhan <spradhan@redhat.com> Reviewed-on: http://review.gluster.org/6852 Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/nfs/server')
-rw-r--r--xlators/nfs/server/src/nfs-fops.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index 60a5a9a843c..14bc0f33ba5 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -317,6 +317,9 @@ nfs_gfid_dict (inode_t *inode)
uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
dyngfid = GF_CALLOC (1, sizeof (uuid_t), gf_common_mt_char);
+ if (dyngfid == NULL)
+ return (NULL);
+
uuid_generate (newgfid);
if (uuid_compare (inode->gfid, rootgfid) == 0)
@@ -327,16 +330,17 @@ nfs_gfid_dict (inode_t *inode)
dictgfid = dict_new ();
if (!dictgfid) {
gf_log (GF_NFS, GF_LOG_ERROR, "Failed to create gfid dict");
- goto out;
+ GF_FREE (dyngfid);
+ return (NULL);
}
ret = dict_set_bin (dictgfid, "gfid-req", dyngfid, sizeof (uuid_t));
if (ret < 0) {
+ GF_FREE (dyngfid);
dict_unref (dictgfid);
- dictgfid = NULL;
+ return (NULL);
}
-out:
return dictgfid;
}