HomeFreeBSD

scsi_cd: Maintain a periph reference during media checks

Description

scsi_cd: Maintain a periph reference during media checks

Otherwise nothing prevents the asynchronous media check state machine
from running after the periph has been destroyed, which can result in a
double free. Acquire the reference even when performing a synchronous
check, since that doesn't hurt and keeps things simpler.

PR: 276251
Reviewed by: imp
Fixes: dd78f43259ef ("scsi_cd: make the media check asynchronous")
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43525