Also release buffer on failed copyout

This commit is contained in:
Frans Kaashoek 2019-08-20 12:46:56 -04:00
parent 6005ef5a1c
commit d98ddadd79

View file

@ -470,8 +470,10 @@ readi(struct inode *ip, int user_dst, uint64 dst, uint off, uint n)
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
bp = bread(ip->dev, 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;