From d98ddadd79ae45dec44f191986bf59136dd15e88 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Tue, 20 Aug 2019 12:46:56 -0400 Subject: [PATCH] Also release buffer on failed copyout --- kernel/fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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;