Fix a client-side memory leak in nfs_flush(). The code allocates

a temporary array to store struct buf pointers if the list doesn't
fit in a local array. Usually it frees the array when finished,
but if it jumps to the 'again' label and the new list does fit in
the local array then it can forget to free a previously malloc'd
M_TEMP memory.

Move the free() up a line so that it frees any previously allocated
memory whether or not it needs to malloc a new array.

Reviewed by:	dillon
This commit is contained in:
Ian Dowse 2001-08-01 10:25:13 +00:00
parent 57a72165c7
commit 02b31a0ee9
2 changed files with 4 additions and 4 deletions

View File

@ -2802,9 +2802,9 @@ nfs_flush(vp, cred, waitfor, p, commit)
* If we can't get memory (for whatever reason), we will end up
* committing the buffers one-by-one in the loop below.
*/
if (bveccount > NFS_COMMITBVECSIZ) {
if (bvec != NULL && bvec != bvec_on_stack)
free(bvec, M_TEMP);
if (bveccount > NFS_COMMITBVECSIZ) {
bvec = (struct buf **)
malloc(bveccount * sizeof(struct buf *),
M_TEMP, M_NOWAIT);

View File

@ -2802,9 +2802,9 @@ nfs_flush(vp, cred, waitfor, p, commit)
* If we can't get memory (for whatever reason), we will end up
* committing the buffers one-by-one in the loop below.
*/
if (bveccount > NFS_COMMITBVECSIZ) {
if (bvec != NULL && bvec != bvec_on_stack)
free(bvec, M_TEMP);
if (bveccount > NFS_COMMITBVECSIZ) {
bvec = (struct buf **)
malloc(bveccount * sizeof(struct buf *),
M_TEMP, M_NOWAIT);