FAT: Fix potential dereference of NULL pointer

* Can occur if bread() returns an error code in readep().
* Fixes #19105.

Change-Id: I975c7d729c59b175c4a6249bbb4660e1294a0ef1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8363
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org>
This commit is contained in:
Jim906 2024-09-24 09:00:12 -04:00 committed by waddlesplash
parent 6b4ccaa5be
commit ed37f3a29d

View File

@ -204,13 +204,16 @@ bawrite(struct buf* bp)
void
brelse(struct buf* bp)
{
if (bp->b_vreg != NULL) {
put_buf(bp);
return;
}
struct mount* bsdVolume = bp->b_vp->v_rdev->si_mountpt;
void* blockCache = bsdVolume->mnt_cache;
bool readOnly = MOUNTED_READ_ONLY(VFSTOMSDOSFS(bsdVolume));
if (bp->b_vreg != NULL) {
put_buf(bp);
} else if (bp->b_owned == false) {
if (bp->b_owned == false) {
if (readOnly == true)
block_cache_set_dirty(blockCache, bp->b_blkno, false, -1);
block_cache_put(blockCache, bp->b_blkno);