diff --git a/kernel/fs.c b/kernel/fs.c index da9bcca..5505408 100644 --- a/kernel/fs.c +++ b/kernel/fs.c @@ -470,8 +470,10 @@ readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n) for(tot=0; totdev, bmap(ip, off/BSIZE)); m = min(n - tot, BSIZE - off%BSIZE); - if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) + if(either_copyout(user_dst, dst, bp->data + (off % BSIZE), m) == -1) { + brelse(bp); break; + } brelse(bp); } return n;