Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs/chfs Plug memory leak in add_peb_to_free() and add_p...



details:   https://anonhg.NetBSD.org/src/rev/3e28cea8f070
branches:  trunk
changeset: 802092:3e28cea8f070
user:      he <he%NetBSD.org@localhost>
date:      Mon Sep 01 16:48:42 2014 +0000

description:
Plug memory leak in add_peb_to_free() and add_peb_to_in_use()
in case there's a duplicate in the tree.

diffstat:

 sys/ufs/chfs/ebh.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r e0f89f58a832 -r 3e28cea8f070 sys/ufs/chfs/ebh.c
--- a/sys/ufs/chfs/ebh.c        Mon Sep 01 16:46:56 2014 +0000
+++ b/sys/ufs/chfs/ebh.c        Mon Sep 01 16:48:42 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ebh.c,v 1.3 2012/08/10 09:26:58 ttoth Exp $    */
+/*     $NetBSD: ebh.c,v 1.4 2014/09/01 16:48:42 he Exp $       */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -828,8 +828,10 @@
        peb->erase_cnt = ec;
        peb->pebnr = pebnr;
        result = RB_INSERT(peb_free_rbtree, &ebh->free, peb);
-       if (result)
+       if (result) {
+               kmem_free(peb, sizeof(struct chfs_peb));
                return 1;
+       }
 
        return 0;
 }
@@ -856,8 +858,10 @@
        peb->erase_cnt = ec;
        peb->pebnr = pebnr;
        result = RB_INSERT(peb_in_use_rbtree, &ebh->in_use, peb);
-       if (result)
+       if (result) {
+               kmem_free(peb, sizeof(struct chfs_peb));
                return 1;
+       }
 
        return 0;
 }



Home | Main Index | Thread Index | Old Index