]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r320123:
authorken <ken@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 26 Jun 2017 15:23:12 +0000 (15:23 +0000)
committerken <ken@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Mon, 26 Jun 2017 15:23:12 +0000 (15:23 +0000)
commit6d218c8826a55d6cb03bdc0a97234f32f5713a56
treea4707eb2d483ebb326151cc2ba1463a763f1adbe
parent5be39ad401e66c571fd3402911bf796d68546f99
MFC r320123:

  Fix a potential sleep while holding a mutex in the sa(4) driver.

  If the user issues a MTIOCEXTGET ioctl, and the tape drive in question has
  a serial number that is longer than 80 characters, we malloc a buffer in
  saextget() to hold the output of cam_strvis().

  Since a mutex is held in that codepath, doing a M_WAITOK malloc could lead
  to sleeping while holding a mutex.  Change it to a M_NOWAIT malloc and bail
  out if we fail to allocate the memory.  Devices with serial numbers longer
  than 80 bytes are very rare (I don't recall seeing one), so this
  should be a very unusual case to hit.  But it is a bug that should be fixed.

  sys/cam/scsi/scsi_sa.c:
   In saextget(), if we need to malloc a buffer to hold the output of
   cam_strvis(), don't wait for the memory.  Fail and return an error
   if we can't allocate the memory immediately.

PR: kern/220094
Submitted by: Jia-Ju Bai <baijiaju1990@163.com>
Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@320361 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/cam/scsi/scsi_sa.c