]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
venus: fix memory leak
authorMarcio Barbosa <mbarbosa@sinenomine.net>
Tue, 31 May 2016 12:08:08 +0000 (09:08 -0300)
committerStephan Wiesand <stephan.wiesand@desy.de>
Sun, 9 Feb 2020 17:52:11 +0000 (12:52 -0500)
In GetPrefCmd, when we request server prefs from the kernel and our
output buffer is not big enough, pioctl() will return E2BIG and we
allocate more memory and try again. However, if the size of the output
buffer reaches 16k bytes and this space is still not enough (or if
pioctl fails and errno != E2BIG), we return without releasing the
memory that was previously allocated.

To fix this problem, free our output buffer when this happens.

Reviewed-on: https://gerrit.openafs.org/12293
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit 8ad4e15ffc883c9a99f9636d7d8a5ed0a2fcc26a)

Change-Id: I62ceddc5284c94da205ec2351ab9ef970cd64c4a
Reviewed-on: https://gerrit.openafs.org/13895
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/venus/fs.c

index 012ecfd52765ed1b4fc35b5109b82c789b2aa77f..52b5df78039576a936d9eb95822581dfc933e7d7 100644 (file)
@@ -3326,6 +3326,9 @@ GetPrefCmd(struct cmd_syndesc *as, void *arock)
            if (code) {
                if ((errno != E2BIG) || (2 * blob.out_size > 0x7FFF)) {
                    perror("getserverprefs pioctl");
+                   if (blob.out != space) {
+                       free(blob.out);
+                   }
                    return 1;
                }
                blob.out_size *= 2;