From b422956c56fa2e98aab198699baa0b0d54097fa4 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 13 Apr 1997 06:27:09 +0000 Subject: [PATCH] The path name buffer, cn->cn_pnbuf, is FREEed by VOP_MKDIR when relookup() in union_relookup() is succeeded. However, if relookup() returns non-zero value, that is relookup fails, VOP_MKDIR is never called (c.f. union_mkshadow). Thus, pathname buffer is never FREEed. Reviewed by: phk Submitted by: kato PR: 3262 --- sys/fs/unionfs/union_subr.c | 6 +++++- sys/miscfs/union/union_subr.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 8868b2a98aa0..e37593d8fd99 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 - * $Id: union_subr.c,v 1.15 1997/03/23 03:36:59 bde Exp $ + * $Id: union_subr.c,v 1.16 1997/04/13 06:25:03 phk Exp $ */ #include @@ -752,6 +752,10 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) error = relookup(dvp, vpp, cn); if (!error) vrele(dvp); + else { + free(cn->cn_pnbuf, M_NAMEI); + cn->cn_pnbuf = '\0'; + } return (error); } diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c index 8868b2a98aa0..e37593d8fd99 100644 --- a/sys/miscfs/union/union_subr.c +++ b/sys/miscfs/union/union_subr.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * @(#)union_subr.c 8.20 (Berkeley) 5/20/95 - * $Id: union_subr.c,v 1.15 1997/03/23 03:36:59 bde Exp $ + * $Id: union_subr.c,v 1.16 1997/04/13 06:25:03 phk Exp $ */ #include @@ -752,6 +752,10 @@ union_relookup(um, dvp, vpp, cnp, cn, path, pathlen) error = relookup(dvp, vpp, cn); if (!error) vrele(dvp); + else { + free(cn->cn_pnbuf, M_NAMEI); + cn->cn_pnbuf = '\0'; + } return (error); }