diff --git a/fs.c b/fs.c index 8531884..ad0e925 100644 --- a/fs.c +++ b/fs.c @@ -136,6 +136,7 @@ static uint bmap(struct inode *ip, uint bn) { struct buf *bp; + uint addr; if(bn < NDIRECT){ return ip->addrs[bn]; @@ -146,7 +147,9 @@ bmap(struct inode *ip, uint bn) // Load indirect block bp = bread(ip->dev, ip->addrs[NDIRECT]); uint *a = (uint*)bp->data; - return a[bn]; + addr = a[bn]; + brelse(bp); + return addr; } panic("bmap: out of range"); @@ -184,4 +187,4 @@ readi(struct inode *ip, char *dst, uint off, uint n) brelse(bp); } return n; -} \ No newline at end of file +}