summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src
diff options
context:
space:
mode:
authorBarak Sason Rofman <bsasonro@redhat.com>2020-07-05 11:15:16 +0300
committerAmar Tumballi <amar@kadalu.io>2020-07-09 04:25:26 +0000
commit79b1992a7ee220d87b0e53ee8b3f83a436366304 (patch)
tree4b0ee0e039f06ab645184de85cdceb0c6adc5b20 /xlators/nfs/server/src
parentbc838bb710fae201df49130a2aedbc76b9fc35e8 (diff)
nfs - fixing coverity issues
Fixing use-after-free issues Change-Id: I33e599da6b8159695e2c9e989421b5877d7200b5 CID: 1430117, 1430138, 1430116 updates: #1202 Signed-off-by: Barak Sason Rofman <bsasonro@redhat.com>
Diffstat (limited to 'xlators/nfs/server/src')
-rw-r--r--xlators/nfs/server/src/acl3.c18
-rw-r--r--xlators/nfs/server/src/acl3.h2
-rw-r--r--xlators/nfs/server/src/mount3.c11
-rw-r--r--xlators/nfs/server/src/nlm4.c12
4 files changed, 34 insertions, 9 deletions
diff --git a/xlators/nfs/server/src/acl3.c b/xlators/nfs/server/src/acl3.c
index 50cd82d..3745188 100644
--- a/xlators/nfs/server/src/acl3.c
+++ b/xlators/nfs/server/src/acl3.c
@@ -571,6 +571,12 @@ acl3_setacl_resume(void *carg)
acl3_check_fh_resolve_status(cs, stat, acl3err);
nfs_request_user_init(&nfu, cs->req);
xattr = dict_new();
+ if (xattr == NULL) {
+ gf_msg(GF_NLM, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto acl3err;
+ }
+
if (cs->aclcount)
ret = dict_set_static_bin(xattr, POSIX_ACL_ACCESS_XATTR, cs->aclxattr,
posix_acl_xattr_size(cs->aclcount));
@@ -724,7 +730,6 @@ acl3svc_init(xlator_t *nfsx)
struct nfs_state *nfs = NULL;
dict_t *options = NULL;
int ret = -1;
- char *portstr = NULL;
static gf_boolean_t acl3_inited = _gf_false;
/* Already inited */
@@ -742,12 +747,14 @@ acl3svc_init(xlator_t *nfsx)
acl3prog.private = ns;
options = dict_new();
-
- ret = gf_asprintf(&portstr, "%d", GF_ACL3_PORT);
- if (ret == -1)
+ if (options == NULL) {
+ gf_msg(GF_ACL, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
goto err;
+ }
- ret = dict_set_dynstr(options, "transport.socket.listen-port", portstr);
+ ret = dict_set_dynstr(options, "transport.socket.listen-port",
+ GF_ACL3_PORT);
if (ret == -1)
goto err;
ret = dict_set_str(options, "transport-type", "socket");
@@ -783,7 +790,6 @@ acl3svc_init(xlator_t *nfsx)
if (ret == -1) {
gf_msg(GF_ACL, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL,
"Unable to create listeners");
- dict_unref(options);
goto err;
}
diff --git a/xlators/nfs/server/src/acl3.h b/xlators/nfs/server/src/acl3.h
index dead04b..762fbb0 100644
--- a/xlators/nfs/server/src/acl3.h
+++ b/xlators/nfs/server/src/acl3.h
@@ -18,7 +18,7 @@
#define ACL3_SETACL 2
#define ACL3_PROC_COUNT 3
-#define GF_ACL3_PORT 38469
+#define GF_ACL3_PORT "38469"
#define GF_ACL GF_NFS "-ACL"
/* Flags for the getacl/setacl mode */
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c
index 88d3002..a34d910 100644
--- a/xlators/nfs/server/src/mount3.c
+++ b/xlators/nfs/server/src/mount3.c
@@ -4062,6 +4062,11 @@ mnt3svc_init(xlator_t *nfsx)
mnt3prog.private = mstate;
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
ret = gf_asprintf(&portstr, "%d", GF_MOUNTV3_PORT);
if (ret == -1)
@@ -4097,7 +4102,6 @@ mnt3svc_init(xlator_t *nfsx)
if (ret == -1) {
gf_msg(GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL,
"Unable to create listeners");
- dict_unref(options);
goto err;
}
@@ -4162,6 +4166,11 @@ mnt1svc_init(xlator_t *nfsx)
mnt1prog.private = mstate;
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
ret = gf_asprintf(&portstr, "%d", GF_MOUNTV1_PORT);
if (ret == -1)
diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c
index ef65d7f..c909e3b 100644
--- a/xlators/nfs/server/src/nlm4.c
+++ b/xlators/nfs/server/src/nlm4.c
@@ -1054,6 +1054,12 @@ nlm4_establish_callback(nfs3_call_state_t *cs, call_frame_t *cbk_frame)
}
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NLM, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
+
ret = dict_set_str(options, "transport-type", "socket");
if (ret == -1) {
gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_DICT_SET_FAILED,
@@ -2592,6 +2598,11 @@ nlm4svc_init(xlator_t *nfsx)
nlm4prog.private = ns;
options = dict_new();
+ if (options == NULL) {
+ gf_msg(GF_NLM, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL,
+ "dict allocation failed");
+ goto err;
+ }
ret = gf_asprintf(&portstr, "%d", GF_NLM4_PORT);
if (ret == -1)
@@ -2633,7 +2644,6 @@ nlm4svc_init(xlator_t *nfsx)
if (ret == -1) {
gf_msg(GF_NLM, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL,
"Unable to create listeners");
- dict_unref(options);
goto err;
}
INIT_LIST_HEAD(&nlm_client_list);