]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afsio: Don't leak memory on GetVenusFidBy* failure
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 19 Feb 2013 17:09:15 +0000 (17:09 +0000)
committerDerrick Brashear <shadow@your-file-system.com>
Fri, 22 Feb 2013 21:04:18 +0000 (13:04 -0800)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
src/venus/afsio.c

index 6e52ea9a2f02e23fb805189a00ce76b5fcb6ef48..8c98707ad7d259d2a8c86cc2eb3d9b5e75d26ef4 100644 (file)
@@ -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;
        }