From 2036534834841641edf3a6d1e142c4798e146b7b Mon Sep 17 00:00:00 2001 From: rtm Date: Fri, 24 Aug 2007 14:56:17 +0000 Subject: add missing iput() at end of _namei() --- fs.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'fs.c') diff --git a/fs.c b/fs.c index e47b6fa..a6e1787 100644 --- a/fs.c +++ b/fs.c @@ -475,6 +475,7 @@ namecmp(const char *s, const char *t) // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. +// Caller must have already locked dp. struct uinode* dirlookup(struct inode *dp, char *name, uint *poff) { @@ -483,7 +484,7 @@ dirlookup(struct inode *dp, char *name, uint *poff) struct dirent *de; if(dp->type != T_DIR) - return 0; + panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += BSIZE){ bp = bread(dp->dev, bmap(dp, off / BSIZE, 0)); @@ -558,7 +559,7 @@ dirlink(struct inode *dp, char *name, uint ino) // // Examples: // skipelem("a/bb/c", name) = "bb/c", setting name = "a" -// skipelem("///a/bb", name) = "b", setting name="a" +// skipelem("///a/bb", name) = "bb", setting name="a" // skipelem("", name) = skipelem("////", name) = 0 // static char* @@ -617,14 +618,15 @@ _namei(char *path, int parent, char *name) if((ipu = dirlookup(dp, name, &off)) == 0){ iput(iunlock(dp)); - iput(ipu); return 0; } iput(iunlock(dp)); dpu = ipu; } - if(parent) + if(parent){ + iput(dpu); return 0; + } return dpu; } -- cgit v1.2.3