From: Simon Wilkinson Date: Tue, 19 Feb 2013 17:09:15 +0000 (+0000) Subject: afsio: Don't leak memory on GetVenusFidBy* failure X-Git-Tag: upstream/1.8.0_pre1^2~1494 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=ba8afdc344a482487008dad325442d71c8bbe526;p=packages%2Fo%2Fopenafs.git afsio: Don't leak memory on GetVenusFidBy* failure The GetVenusFid functions all allocate the fid structure immediately upon entry to the function. When we return with an error, that structure is never freed. Update the call sites so that we don't leak this memory. Caught by clang-analyzer Change-Id: Iec62316d0fd542e70634f384c8319f90ba6b2649 Reviewed-on: http://gerrit.openafs.org/9187 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/venus/afsio.c b/src/venus/afsio.c index 6e52ea9a2..8c98707ad 100644 --- a/src/venus/afsio.c +++ b/src/venus/afsio.c @@ -685,6 +685,7 @@ lockFile(struct cmd_syndesc *as, void *arock) code = GetVenusFidByPath(fname, cell, &avfp); if (code != 0) { afs_com_err(pnp, code, "(file not found: %s)", fname); + afscp_FreeFid(avfp); return code; } @@ -772,6 +773,7 @@ readFile(struct cmd_syndesc *as, void *unused) else code = GetVenusFidByPath(fname, cell, &avfp); if (code != 0) { + afscp_FreeFid(avfp); afs_com_err(pnp, code, "(file not found: %s)", fname); return code; } @@ -896,6 +898,7 @@ writeFile(struct cmd_syndesc *as, void *unused) if (useFid) { code = GetVenusFidByFid(fname, cell, 1, &newvfp); if (code != 0) { + afscp_FreeFid(newvfp); afs_com_err(pnp, code, "(GetVenusFidByFid returned code %d)", code); return code; }