From e849fbc4a8d86ef96c91a4011b1a57f4d7bf725c Mon Sep 17 00:00:00 2001 From: Marcio Barbosa Date: Tue, 31 May 2016 09:08:08 -0300 Subject: [PATCH] venus: fix memory leak 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 Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit 8ad4e15ffc883c9a99f9636d7d8a5ed0a2fcc26a) Change-Id: I62ceddc5284c94da205ec2351ab9ef970cd64c4a Reviewed-on: https://gerrit.openafs.org/13895 Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Cheyenne Wills Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/venus/fs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/venus/fs.c b/src/venus/fs.c index 012ecfd52..52b5df780 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -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; -- 2.39.5