From cc4916adf2c3f310008e78adb40a94238724d606 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Tue, 29 Mar 2016 19:59:44 +0000 Subject: [PATCH] Do not access buffer if bread(9) or cluster_read(9) failed. On error, the functions free the buffer and set the pointer to NULL. Also remove useless call to brelse(9) on the error path. PR: 208275 Submitted by: Fabian Keil MFC after: 2 weeks --- sys/fs/cd9660/cd9660_vnops.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 47d4f757713e..cab8db7e39dc 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -341,11 +341,9 @@ cd9660_read(ap) } else error = bread(vp, lbn, size, NOCRED, &bp); } - n = MIN(n, size - bp->b_resid); - if (error) { - brelse(bp); + if (error != 0) return (error); - } + n = MIN(n, size - bp->b_resid); error = uiomove(bp->b_data + on, (int)n, uio); brelse(bp);