Re: possible memory leak in 2.0.29 - patch

David S. Miller (davem@jenolan.rutgers.edu)
Wed, 9 Apr 1997 18:13:35 -0400


Seems pretty sane, I've made this change in my tree and will merge it
to Linus before 2.0.31 is released some time in the future, I rewrote
it slightly to perhaps make is cleaner but more importantly to make
the common code path slightly smaller:

--- fork.c.~1~ Mon Apr 7 23:30:25 1997
+++ fork.c Wed Apr 9 18:11:48 1997
@@ -129,16 +129,20 @@
tsk->cmin_flt = tsk->cmaj_flt = 0;
tsk->nswap = tsk->cnswap = 0;
if (new_page_tables(tsk))
- return -1;
- if (dup_mmap(mm)) {
- free_page_tables(mm);
- return -1;
- }
+ goto npt_fail;
+ if (dup_mmap(mm))
+ goto dupmmap_fail;
return 0;
}
SET_PAGE_DIR(tsk, current->mm->pgd);
current->mm->count++;
return 0;
+
+dupmmap_fail:
+ free_page_tables(mm);
+npt_fail:
+ kfree(mm);
+ return -1;
}

static inline int copy_fs(unsigned long clone_flags, struct task_struct * tsk)