* [PATCH 01/19] Removed resource leaks from junction/path.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 02/19] Removed resource leaks from nfs/exports.c Steve Dickson
` (18 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
junction/path.c:167: leaked_storage: Variable "start" going out
of scope leaks the storage it points to.
junction/path.c:331: leaked_storage: Variable "normalized" going out
of scope leaks the storage it points to.
junction/path.c:340: leaked_storage: Variable "normalized" going out
of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/junction/path.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/support/junction/path.c b/support/junction/path.c
index e74e4c4..13a1438 100644
--- a/support/junction/path.c
+++ b/support/junction/path.c
@@ -163,8 +163,10 @@ nsdb_count_components(const char *pathname, size_t *len,
break;
next = strchrnul(component, '/');
tmp = (size_t)(next - component);
- if (tmp > 255)
+ if (tmp > 255) {
+ free(start);
return false;
+ }
length += XDR_UINT_BYTES + (nsdb_quadlen(tmp) << 2);
count++;
@@ -328,11 +330,13 @@ nsdb_posix_to_path_array(const char *pathname, char ***path_array)
length = (size_t)(next - component);
if (length > 255) {
nsdb_free_string_array(result);
+ free(normalized);
return FEDFS_ERR_SVRFAULT;
}
result[i] = strndup(component, length);
if (result[i] == NULL) {
+ free(normalized);
nsdb_free_string_array(result);
return FEDFS_ERR_SVRFAULT;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 02/19] Removed resource leaks from nfs/exports.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
2019-05-08 13:35 ` [PATCH 01/19] Removed resource leaks from junction/path.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 03/19] Removed a resource leak from nfs/mydaemon.c Steve Dickson
` (17 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfs/exports.c:717: leaked_storage: Variable "id" going out
of scope leaks the storage it points to.
nfs/exports.c:727: leaked_storage: Variable "id" going out
of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/exports.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/support/nfs/exports.c b/support/nfs/exports.c
index b59d187..5f4cb95 100644
--- a/support/nfs/exports.c
+++ b/support/nfs/exports.c
@@ -714,6 +714,7 @@ parsesquash(char *list, int **idp, int *lenp, char **ep)
}
if (id0 == -1 || id1 == -1) {
syntaxerr("uid/gid -1 not permitted");
+ xfree(id);
return -1;
}
if ((len % 8) == 0)
@@ -724,6 +725,7 @@ parsesquash(char *list, int **idp, int *lenp, char **ep)
break;
if (*cp != ',') {
syntaxerr("bad uid/gid list");
+ xfree(id);
return -1;
}
cp++;
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 03/19] Removed a resource leak from nfs/mydaemon.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
2019-05-08 13:35 ` [PATCH 01/19] Removed resource leaks from junction/path.c Steve Dickson
2019-05-08 13:35 ` [PATCH 02/19] Removed resource leaks from nfs/exports.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 04/19] Removed a resource leak from nfs/rpcmisc.c Steve Dickson
` (16 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfs/mydaemon.c:130: leaked_handle: Handle variable "tempfd"
going out of scope leaks the handle.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/mydaemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/support/nfs/mydaemon.c b/support/nfs/mydaemon.c
index 343e80b..d1cf08d 100644
--- a/support/nfs/mydaemon.c
+++ b/support/nfs/mydaemon.c
@@ -123,6 +123,7 @@ daemon_init(bool fg)
dup2(tempfd, 0);
dup2(tempfd, 1);
dup2(tempfd, 2);
+ close(tempfd);
closelog();
dup2(pipefds[1], 3);
pipefds[1] = 3;
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 04/19] Removed a resource leak from nfs/rpcmisc.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (2 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 03/19] Removed a resource leak from nfs/mydaemon.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 05/19] Removed a resource leak from nfs/svc_socket.c Steve Dickson
` (15 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfs/rpcmisc.c:105: leaked_handle: Handle variable "sock"
going out of scope leaks the handle.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/rpcmisc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c
index abe89ba..d84c04f 100644
--- a/support/nfs/rpcmisc.c
+++ b/support/nfs/rpcmisc.c
@@ -102,6 +102,7 @@ makesock(int port, int proto)
if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
xlog(L_FATAL, "Could not bind name to socket: %s",
strerror(errno));
+ close(sock);
return -1;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 05/19] Removed a resource leak from nfs/svc_socket.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (3 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 04/19] Removed a resource leak from nfs/rpcmisc.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 06/19] Removed bad frees from nfs/xcommon.c Steve Dickson
` (14 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfs/svc_socket.c:137: leaked_handle: Handle variable "sock"
going out of scope leaks the handle.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/svc_socket.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/support/nfs/svc_socket.c b/support/nfs/svc_socket.c
index d56507a..5afc6aa 100644
--- a/support/nfs/svc_socket.c
+++ b/support/nfs/svc_socket.c
@@ -134,6 +134,7 @@ svc_socket (u_long number, int type, int protocol, int reuse)
if (ret < 0)
{
xlog(L_ERROR, "svc_socket: socket reuse problem: %m");
+ (void) __close(sock);
return ret;
}
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 06/19] Removed bad frees from nfs/xcommon.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (4 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 05/19] Removed a resource leak from nfs/svc_socket.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 07/19] Removed resource leaks from nfs/xlog.c Steve Dickson
` (13 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfs/xcommon.c:63: incorrect_free: "free" frees incorrect pointer "(void *)s".
nfs/xcommon.c:81: incorrect_free: "free" frees incorrect pointer "(void *)s".
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/xcommon.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c
index 14e580e..3989f0b 100644
--- a/support/nfs/xcommon.c
+++ b/support/nfs/xcommon.c
@@ -53,14 +53,17 @@ char *
xstrconcat3 (const char *s, const char *t, const char *u) {
char *res;
- if (!s) s = "";
+ int dofree = 1;
+
+ if (!s) s = "", dofree=0;
if (!t) t = "";
if (!u) u = "";
res = xmalloc(strlen(s) + strlen(t) + strlen(u) + 1);
strcpy(res, s);
strcat(res, t);
strcat(res, u);
- free((void *) s);
+ if (dofree)
+ free((void *) s);
return res;
}
@@ -69,7 +72,9 @@ char *
xstrconcat4 (const char *s, const char *t, const char *u, const char *v) {
char *res;
- if (!s) s = "";
+ int dofree = 1;
+
+ if (!s) s = "", dofree=0;
if (!t) t = "";
if (!u) u = "";
if (!v) v = "";
@@ -78,7 +83,8 @@ xstrconcat4 (const char *s, const char *t, const char *u, const char *v) {
strcat(res, t);
strcat(res, u);
strcat(res, v);
- free((void *) s);
+ if (dofree)
+ free((void *) s);
return res;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 07/19] Removed resource leaks from nfs/xlog.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (5 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 06/19] Removed bad frees from nfs/xcommon.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 08/19] Removed resource leaks from nfsidmap/libnfsidmap.c Steve Dickson
` (12 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfs/xlog.c:139: leaked_storage: Variable "kinds" going out
of scope leaks the storage it points to.
nfs/xlog.c:142: leaked_storage: Variable "kinds" going out
of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfs/xlog.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/support/nfs/xlog.c b/support/nfs/xlog.c
index f75a9ab..687d862 100644
--- a/support/nfs/xlog.c
+++ b/support/nfs/xlog.c
@@ -135,10 +135,14 @@ xlog_from_conffile(char *service)
struct conf_list_node *n;
kinds = conf_get_list(service, "debug");
- if (!kinds || !kinds->cnt)
+ if (!kinds || !kinds->cnt) {
+ free(kinds);
return;
+ }
TAILQ_FOREACH(n, &(kinds->fields), link)
xlog_sconfig(n->field, 1);
+
+ conf_free_list(kinds);
}
int
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 08/19] Removed resource leaks from nfsidmap/libnfsidmap.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (6 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 07/19] Removed resource leaks from nfs/xlog.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 09/19] Removed resource leaks from nfsidmap/static.c Steve Dickson
` (11 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfsidmap/libnfsidmap.c:410: leaked_storage: Variable "nfs4_methods"
going out of scope leaks the storage it points to.
ibnfsidmap.c:483: leaked_storage: Variable "gss_methods"
going out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfsidmap/libnfsidmap.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index 35ddf01..7b8a871 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -406,8 +406,10 @@ int nfs4_init_name_mapping(char *conffile)
nfs4_methods = conf_get_list("Translation", "Method");
if (nfs4_methods) {
IDMAP_LOG(1, ("libnfsidmap: processing 'Method' list"));
- if (load_plugins(nfs4_methods, &nfs4_plugins) == -1)
+ if (load_plugins(nfs4_methods, &nfs4_plugins) == -1) {
+ conf_free_list(nfs4_methods);
return -ENOENT;
+ }
} else {
struct conf_list list;
struct conf_list_node node;
@@ -475,11 +477,15 @@ out:
if (ret) {
if (nfs4_plugins)
unload_plugins(nfs4_plugins);
- if (gss_plugins)
+ if (gss_plugins) {
unload_plugins(gss_plugins);
+ }
nfs4_plugins = gss_plugins = NULL;
}
+ if (gss_methods)
+ conf_free_list(gss_methods);
+
return ret ? -ENOENT: 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 09/19] Removed resource leaks from nfsidmap/static.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (7 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 08/19] Removed resource leaks from nfsidmap/libnfsidmap.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 10/19] Removed a resource leak from nsm/file.c Steve Dickson
` (10 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfsidmap/static.c:350: leaked_storage: Variable "princ_list"
going out of scope leaks the storage it points to.
nfsidmap/static.c:358: leaked_storage: Variable "princ_list"
going out of scope leaks the storage it points to.
nfsidmap/static.c:360: leaked_storage: Variable "unode"
going out of scope leaks the storage it points to.
nfsidmap/static.c:382: leaked_storage: Variable "princ_list"
going out of scope leaks the storage it points to.
nfsidmap/static.c:390: leaked_storage: Variable "gnode"
going out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nfsidmap/static.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/support/nfsidmap/static.c b/support/nfsidmap/static.c
index f7b8a67..8ac4a39 100644
--- a/support/nfsidmap/static.c
+++ b/support/nfsidmap/static.c
@@ -347,6 +347,7 @@ static int static_init(void) {
warnx("static_init: calloc (1, %lu) failed",
(unsigned long)sizeof *unode);
free(pw);
+ conf_free_list(princ_list);
return -ENOMEM;
}
unode->uid = pw->pw_uid;
@@ -355,6 +356,9 @@ static int static_init(void) {
unode->localname = conf_get_str("Static", cln->field);
if (!unode->localname) {
free(pw);
+ free(unode->principal);
+ free(unode);
+ conf_free_list(princ_list);
return -ENOENT;
}
@@ -379,6 +383,7 @@ static int static_init(void) {
warnx("static_init: calloc (1, %lu) failed",
(unsigned long)sizeof *gnode);
free(gr);
+ conf_free_list(princ_list);
return -ENOMEM;
}
gnode->gid = gr->gr_gid;
@@ -387,6 +392,9 @@ static int static_init(void) {
gnode->localgroup = conf_get_str("Static", cln->field);
if (!gnode->localgroup) {
free(gr);
+ free(gnode->principal);
+ free(gnode);
+ conf_free_list(princ_list);
return -ENOENT;
}
@@ -394,6 +402,8 @@ static int static_init(void) {
LIST_INSERT_HEAD (&gid_mappings[gid_hash(gnode->gid)], gnode, link);
}
+
+ conf_free_list(princ_list);
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 10/19] Removed a resource leak from nsm/file.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (8 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 09/19] Removed resource leaks from nfsidmap/static.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 11/19] Removed resource leaks from systemd/rpc-pipefs-generator.c Steve Dickson
` (9 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nsm/file.c:536: leaked_handle: Handle variable "fd" going
out of scope leaks the handle
Signed-off-by: Steve Dickson <steved@redhat.com>
---
support/nsm/file.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/support/nsm/file.c b/support/nsm/file.c
index 52f5401..0b66f12 100644
--- a/support/nsm/file.c
+++ b/support/nsm/file.c
@@ -533,6 +533,7 @@ nsm_update_kernel_state(const int state)
len = snprintf(buf, sizeof(buf), "%d", state);
if (error_check(len, sizeof(buf))) {
xlog_warn("Failed to form NSM state number string");
+ close(fd);
return;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 11/19] Removed resource leaks from systemd/rpc-pipefs-generator.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (9 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 10/19] Removed a resource leak from nsm/file.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 12/19] Removed resource leaks from blkmapd/device-discovery.c Steve Dickson
` (8 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
systemd/rpc-pipefs-generator.c:73: leaked_storage: Variable "pipefs_unit"
going out of scope leaks the storage it points to
systemd/rpc-pipefs-generator.c:77: leaked_storage: Variable "pipefs_unit"
going out of scope leaks the storage it points to.
systemd/rpc-pipefs-generator.c:85: leaked_storage: Variable "pipefs_unit"
going out of scope leaks the storage it points to.
systemd/rpc-pipefs-generator.c:94: leaked_storage: Variable "pipefs_unit"
going out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
systemd/rpc-pipefs-generator.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/systemd/rpc-pipefs-generator.c b/systemd/rpc-pipefs-generator.c
index 0b5da11..8e218aa 100644
--- a/systemd/rpc-pipefs-generator.c
+++ b/systemd/rpc-pipefs-generator.c
@@ -69,12 +69,16 @@ int generate_target(char *pipefs_path, const char *dirname)
return 1;
ret = generate_mount_unit(pipefs_path, pipefs_unit, dirname);
- if (ret)
+ if (ret) {
+ free(pipefs_unit);
return ret;
+ }
path = malloc(strlen(dirname) + 1 + sizeof(filebase));
- if (!path)
+ if (!path) {
+ free(pipefs_unit);
return 2;
+ }
sprintf(path, "%s", dirname);
mkdir(path, 0755);
strcat(path, filebase);
@@ -82,6 +86,7 @@ int generate_target(char *pipefs_path, const char *dirname)
if (!f)
{
free(path);
+ free(pipefs_unit);
return 1;
}
@@ -90,6 +95,7 @@ int generate_target(char *pipefs_path, const char *dirname)
fprintf(f, "After=%s\n", pipefs_unit);
fclose(f);
free(path);
+ free(pipefs_unit);
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 12/19] Removed resource leaks from blkmapd/device-discovery.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (10 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 11/19] Removed resource leaks from systemd/rpc-pipefs-generator.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 13/19] Removed resource leaks from gssd/krb5_util.c Steve Dickson
` (7 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
blkmapd/device-discovery.c:190: leaked_storage: Variable "serial"
going out of scope leaks the storage it points to.
blkmapd/device-discovery.c:378: overwrite_var: Overwriting handle
"bl_pipe_fd" in "bl_pipe_fd = open(bl_pipe_file, 2)" leaks the handle.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/blkmapd/device-discovery.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
index 2ce60f8..e811703 100644
--- a/utils/blkmapd/device-discovery.c
+++ b/utils/blkmapd/device-discovery.c
@@ -186,8 +186,13 @@ static void bl_add_disk(char *filepath)
}
}
- if (disk && diskpath)
+ if (disk && diskpath) {
+ if (serial) {
+ free(serial->data);
+ free(serial);
+ }
return;
+ }
/* add path */
path = malloc(sizeof(struct bl_disk_path));
@@ -223,6 +228,10 @@ static void bl_add_disk(char *filepath)
disk->size = size;
disk->valid_path = path;
}
+ if (serial) {
+ free(serial->data);
+ free(serial);
+ }
}
return;
@@ -232,6 +241,10 @@ static void bl_add_disk(char *filepath)
free(path->full_path);
free(path);
}
+ if (serial) {
+ free(serial->data);
+ free(serial);
+ }
return;
}
@@ -375,7 +388,12 @@ static void bl_rpcpipe_cb(void)
if (event->mask & IN_CREATE) {
BL_LOG_WARNING("nfs pipe dir created\n");
bl_watch_dir(nfspipe_dir, &nfs_pipedir_wfd);
+ if (bl_pipe_fd >= 0)
+ close(bl_pipe_fd);
bl_pipe_fd = open(bl_pipe_file, O_RDWR);
+ if (bl_pipe_fd < 0)
+ BL_LOG_ERR("open %s failed: %s\n",
+ event->name, strerror(errno));
} else if (event->mask & IN_DELETE) {
BL_LOG_WARNING("nfs pipe dir deleted\n");
inotify_rm_watch(bl_watch_fd, nfs_pipedir_wfd);
@@ -388,6 +406,8 @@ static void bl_rpcpipe_cb(void)
continue;
if (event->mask & IN_CREATE) {
BL_LOG_WARNING("blocklayout pipe file created\n");
+ if (bl_pipe_fd >= 0)
+ close(bl_pipe_fd);
bl_pipe_fd = open(bl_pipe_file, O_RDWR);
if (bl_pipe_fd < 0)
BL_LOG_ERR("open %s failed: %s\n",
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 13/19] Removed resource leaks from gssd/krb5_util.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (11 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 12/19] Removed resource leaks from blkmapd/device-discovery.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 14/19] Removed a resource leak from mount/configfile.c Steve Dickson
` (6 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
gssd/krb5_util.c:696: overwrite_var: Overwriting "k5err" in
"k5err = gssd_k5_err_msg(context, code)" leaks
the storage that "k5err" points to.
gssd/krb5_util.c:737: overwrite_var: Overwriting "k5err" in
"k5err = gssd_k5_err_msg(context, code)" leaks
the storage that "k5err" points to.
gssd/krb5_util.c:899: overwrite_var: Overwriting "k5err" in
"k5err = gssd_k5_err_msg(context, code)" leaks
the storage that "k5err" points to.
krb5_util.c:1173: leaked_storage: Variable "l" going out
of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/gssd/krb5_util.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c
index 6daba44..454a6eb 100644
--- a/utils/gssd/krb5_util.c
+++ b/utils/gssd/krb5_util.c
@@ -699,6 +699,8 @@ gssd_search_krb5_keytab(krb5_context context, krb5_keytab kt,
"we failed to unparse principal name: %s\n",
k5err);
k5_free_kt_entry(context, kte);
+ free(k5err);
+ k5err = NULL;
continue;
}
printerr(4, "Processing keytab entry for principal '%s'\n",
@@ -900,6 +902,8 @@ find_keytab_entry(krb5_context context, krb5_keytab kt,
k5err = gssd_k5_err_msg(context, code);
printerr(1, "%s while building principal for '%s'\n",
k5err, spn);
+ free(k5err);
+ k5err = NULL;
continue;
}
code = krb5_kt_get_entry(context, kt, princ, 0, 0, kte);
@@ -1169,7 +1173,8 @@ gssd_get_krb5_machine_cred_list(char ***list)
*list = l;
retval = 0;
goto out;
- }
+ } else
+ free((void *)l);
out:
return retval;
}
@@ -1217,6 +1222,8 @@ gssd_destroy_krb5_machine_creds(void)
printerr(0, "WARNING: %s while resolving credential "
"cache '%s' for destruction\n", k5err,
ple->ccname);
+ free(k5err);
+ k5err = NULL;
continue;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 14/19] Removed a resource leak from mount/configfile.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (12 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 13/19] Removed resource leaks from gssd/krb5_util.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 15/19] Removed a resource leak from mount/nfsmount.c Steve Dickson
` (5 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
mount/configfile.c:410: leaked_storage: Variable "config_opts"
going out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/mount/configfile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utils/mount/configfile.c b/utils/mount/configfile.c
index b48b25e..93fe500 100644
--- a/utils/mount/configfile.c
+++ b/utils/mount/configfile.c
@@ -404,7 +404,7 @@ char *conf_get_mntopts(char *spec, char *mount_point,
/* list_size + optlen + ',' + '\0' */
config_opts = calloc(1, (list_size+optlen+2));
- if (server == NULL) {
+ if (config_opts == NULL) {
xlog_warn("conf_get_mountops: Unable calloc memory for config_opts");
free_all();
return mount_opts;
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 15/19] Removed a resource leak from mount/nfsmount.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (13 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 14/19] Removed a resource leak from mount/configfile.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 16/19] Removed a resource leak from mount/stropts.c Steve Dickson
` (4 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
mount/nfsmount.c:455: leaked_storage: Variable "mounthost" going
out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/mount/nfsmount.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/utils/mount/nfsmount.c b/utils/mount/nfsmount.c
index 952a755..3d95da9 100644
--- a/utils/mount/nfsmount.c
+++ b/utils/mount/nfsmount.c
@@ -452,6 +452,7 @@ parse_options(char *old_opts, struct nfs_mount_data *data,
nfs_error(_("%s: Bad nfs mount parameter: %s\n"), progname, opt);
out_bad:
free(tmp_opts);
+ free(mounthost);
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 16/19] Removed a resource leak from mount/stropts.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (14 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 15/19] Removed a resource leak from mount/nfsmount.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 17/19] Removed resource leaks from mountd/cache.c Steve Dickson
` (3 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
mount/stropts.c:986: leaked_storage: Variable "address"
going out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/mount/stropts.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index a093926..1bb7a73 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -983,8 +983,11 @@ static int nfs_try_mount(struct nfsmount_info *mi)
}
if (!nfs_append_addr_option(address->ai_addr,
- address->ai_addrlen, mi->options))
+ address->ai_addrlen, mi->options)) {
+ nfs_freeaddrinfo(address);
+ errno = ENOMEM;
return 0;
+ }
mi->address = address;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 17/19] Removed resource leaks from mountd/cache.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (15 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 16/19] Removed a resource leak from mount/stropts.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 18/19] Removed a resource leak from mountd/fsloc.c Steve Dickson
` (2 subsequent siblings)
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
mountd/cache.c:1244:3: warning: statement will never be
executed [-Wswitch-unreachable]
mountd/cache.c:1260: leaked_storage: Variable "locations"
going out of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/mountd/cache.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c
index 2cb370f..bdbd190 100644
--- a/utils/mountd/cache.c
+++ b/utils/mountd/cache.c
@@ -1240,7 +1240,7 @@ static struct exportent *lookup_junction(char *dom, const char *pathname,
goto out;
}
status = nfs_get_basic_junction(pathname, &locations);
- switch (status) {
+ if (status) {
xlog(L_WARNING, "Dangling junction %s: %s",
pathname, strerror(status));
goto out;
@@ -1248,10 +1248,11 @@ static struct exportent *lookup_junction(char *dom, const char *pathname,
parent = lookup_parent_export(dom, pathname, ai);
if (parent == NULL)
- goto out;
+ goto free_locations;
exp = locations_to_export(locations, pathname, parent);
+free_locations:
nfs_free_locations(locations->ns_list);
free(locations);
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 18/19] Removed a resource leak from mountd/fsloc.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (16 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 17/19] Removed resource leaks from mountd/cache.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-08 13:35 ` [PATCH 19/19] Removed a resource leak from nfsdcltrack/sqlite.c Steve Dickson
2019-05-10 15:07 ` [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
mountd/fsloc.c:97: overwrite_var: Overwriting "mp" in
"mp = calloc(1UL, 16UL)" leaks the storage that "mp" points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/mountd/fsloc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/utils/mountd/fsloc.c b/utils/mountd/fsloc.c
index bc737d1..cf42944 100644
--- a/utils/mountd/fsloc.c
+++ b/utils/mountd/fsloc.c
@@ -102,6 +102,7 @@ static struct servers *parse_list(char **list)
cp = strchr(list[i], '@');
if ((!cp) || list[i][0] != '/') {
xlog(L_WARNING, "invalid entry '%s'", list[i]);
+ free(mp);
continue; /* XXX Need better error handling */
}
res->h_mp[i] = mp;
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [PATCH 19/19] Removed a resource leak from nfsdcltrack/sqlite.c
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (17 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 18/19] Removed a resource leak from mountd/fsloc.c Steve Dickson
@ 2019-05-08 13:35 ` Steve Dickson
2019-05-10 15:07 ` [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-08 13:35 UTC (permalink / raw)
To: Linux NFS Mailing list
nfsdcltrack/sqlite.c:218: leaked_storage: Variable "err" going out
of scope leaks the storage it points to.
Signed-off-by: Steve Dickson <steved@redhat.com>
---
utils/nfsdcltrack/sqlite.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/utils/nfsdcltrack/sqlite.c b/utils/nfsdcltrack/sqlite.c
index c59f777..2801201 100644
--- a/utils/nfsdcltrack/sqlite.c
+++ b/utils/nfsdcltrack/sqlite.c
@@ -215,6 +215,8 @@ sqlite_maindb_init_v2(void)
&err);
if (ret != SQLITE_OK) {
xlog(L_ERROR, "Unable to begin transaction: %s", err);
+ if (err)
+ sqlite3_free(err);
return ret;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [PATCH 00/19] Covertity Scan: Removed resources leaks
2019-05-08 13:35 [PATCH 00/19] Covertity Scan: Removed resources leaks Steve Dickson
` (18 preceding siblings ...)
2019-05-08 13:35 ` [PATCH 19/19] Removed a resource leak from nfsdcltrack/sqlite.c Steve Dickson
@ 2019-05-10 15:07 ` Steve Dickson
19 siblings, 0 replies; 21+ messages in thread
From: Steve Dickson @ 2019-05-10 15:07 UTC (permalink / raw)
To: Linux NFS Mailing list
On 5/8/19 9:35 AM, Steve Dickson wrote:
> Red Hat is now requiring covertity scans
> to be run against all RHEL 8 packages.
>
> These patches removed the majority of the
> resource leaks that were flagged by the scan.
>
> Most of the leaks were in return and error
> paths as well as some obvious problems like
> checking the wrong point to be NULL.
>
> There are still a few resources leaks
> and used_after_freed being flagged but
> I am thinking they false-positives
> because I just don't see the problem.
>
> I've tested these patches for a couple
> days and they seem stable... but whenever
> free()s are added... So is risk of freeing
> that is still being used. Plus they will
> get a good workout at the upcoming Bakeathon.
>
> Steve Dickson (19):
> Removed resource leaks from junction/path.c
> Removed resource leaks from nfs/exports.c
> Removed a resource leak from nfs/mydaemon.c
> Removed a resource leak from nfs/rpcmisc.c
> Removed a resource leak from nfs/svc_socket.c
> Removed bad frees from nfs/xcommon.c
> Removed resource leaks from nfs/xlog.c
> Removed resource leaks from nfsidmap/libnfsidmap.c
> Removed resource leaks from nfsidmap/static.c
> Removed a resource leak from nsm/file.c
> Removed resource leaks from systemd/rpc-pipefs-generator.c
> Removed resource leaks from blkmapd/device-discovery.c
> Removed resource leaks from gssd/krb5_util.c
> Removed a resource leak from mount/configfile.c
> Removed a resource leak from mount/nfsmount.c
> Removed a resource leak from mount/stropts.c
> Removed resource leaks from mountd/cache.c
> Removed a resource leak from mountd/fsloc.c
> Removed a resource leak from nfsdcltrack/sqlite.c
>
> support/junction/path.c | 6 +++++-
> support/nfs/exports.c | 2 ++
> support/nfs/mydaemon.c | 1 +
> support/nfs/rpcmisc.c | 1 +
> support/nfs/svc_socket.c | 1 +
> support/nfs/xcommon.c | 14 ++++++++++----
> support/nfs/xlog.c | 6 +++++-
> support/nfsidmap/libnfsidmap.c | 10 ++++++++--
> support/nfsidmap/static.c | 10 ++++++++++
> support/nsm/file.c | 1 +
> systemd/rpc-pipefs-generator.c | 10 ++++++++--
> utils/blkmapd/device-discovery.c | 22 +++++++++++++++++++++-
> utils/gssd/krb5_util.c | 9 ++++++++-
> utils/mount/configfile.c | 2 +-
> utils/mount/nfsmount.c | 1 +
> utils/mount/stropts.c | 5 ++++-
> utils/mountd/cache.c | 5 +++--
> utils/mountd/fsloc.c | 1 +
> utils/nfsdcltrack/sqlite.c | 2 ++
> 19 files changed, 93 insertions(+), 16 deletions(-)
>
Committed...
steved.
^ permalink raw reply [flat|nested] 21+ messages in thread