mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04: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
1 changed files with 7 additions and 6 deletions
|
|
@ -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 a new issue