On error, bread(9) zeroes buffer pointer, do not dereference it.

See r294954 for the bread(9) change and r297401 for similar cd9660 fix.

Reported and tested by:	Joshua Kinard <kumba@gentoo.org>
PR:	214705
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2016-11-22 13:24:57 +00:00
parent 9170c18bb9
commit 1fa81dab7d

View File

@ -487,11 +487,11 @@ udf_read(struct vop_read_args *ap)
} else {
error = bread(vp, lbn, size, NOCRED, &bp);
}
n = min(n, size - bp->b_resid);
if (error) {
if (error != 0) {
brelse(bp);
return (error);
}
n = min(n, size - bp->b_resid);
error = uiomove(bp->b_data + on, (int)n, uio);
brelse(bp);