mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-19 02:29:40 +00:00
Fix a locking mistake in daopen(). If the open fails, which can happen
because the media was removed, the periph would get its refcount dropped and ultimately freed before getting unlocked. This created a dangling pointer that was easy to trip over. This fixes a common source of crashes with removaable media, but problems remain and will get tracked down.
This commit is contained in:
parent
f6cd36de6f
commit
b574dd8dd1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182433
@ -674,18 +674,19 @@ daopen(struct disk *dp)
|
||||
softc->disk->d_fwheads = softc->params.heads;
|
||||
softc->disk->d_devstat->block_size = softc->params.secsize;
|
||||
softc->disk->d_devstat->flags &= ~DEVSTAT_BS_UNAVAILABLE;
|
||||
}
|
||||
|
||||
if (error == 0) {
|
||||
|
||||
if ((softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 &&
|
||||
(softc->quirks & DA_Q_NO_PREVENT) == 0)
|
||||
daprevent(periph, PR_PREVENT);
|
||||
} else {
|
||||
} else
|
||||
softc->flags &= ~DA_FLAG_OPEN;
|
||||
cam_periph_release(periph);
|
||||
}
|
||||
|
||||
cam_periph_unhold(periph);
|
||||
cam_periph_unlock(periph);
|
||||
|
||||
if (error != 0) {
|
||||
cam_periph_release(periph);
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user