Patchwork [08/12] fedfsd: don't double-free upon ENOMEM

login
register
mail settings
Submitter Chuck Lever
Date Dec. 13, 2011, 10:52 p.m.
Message ID <20111213225208.15402.69374.stgit@degas.1015granger.net>
Download mbox | patch
Permalink /patch/131208/
State Accepted
Headers show

Comments

Chuck Lever - Dec. 13, 2011, 10:52 p.m.
From: Jim Meyering <meyering@redhat.com>

* src/fedfsd/svc.c (fedfsd_pathwalk): If nsdb_normalize_path were
to return NULL, "result" would be freed once by the very next stmt,
and then again in the following "if"-block.  Remove the latter.
Spotted by coverity.

Introduced by commit 0520ee72: "Initial commit," (March 29, 2011).

Signed-off-by: Jim Meyering <meyering@redhat.com>
---

 src/fedfsd/svc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

Patch

diff --git a/src/fedfsd/svc.c b/src/fedfsd/svc.c
index 12940c7..3b08272 100644
--- a/src/fedfsd/svc.c
+++ b/src/fedfsd/svc.c
@@ -377,10 +377,8 @@  fedfsd_pathwalk(const FedFsPathName fpath, char **pathname)
 
 	tmp = nsdb_normalize_path(result);
 	free(result);
-	if (tmp == NULL) {
-		free(result);
+	if (tmp == NULL)
 		return FEDFS_ERR_SVRFAULT;
-	}
 
 	retval = fedfsd_pathwalk_check_term(tmp);
 	switch (retval) {