Also release buffer on failed copyout
This commit is contained in:
parent
6005ef5a1c
commit
d98ddadd79
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue