aboutsummaryrefslogtreecommitdiffstats
path: root/sys/cam/nvme/nvme_da.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-01-26 23:14:46 +0000
committerWarner Losh <imp@FreeBSD.org>2018-01-26 23:14:46 +0000
commit60b7691d56f29d848a57bfc062d41f87cce061f0 (patch)
treecf6911ab32cc8d80d78409f6dbc98549d1e7ab55 /sys/cam/nvme/nvme_da.c
parent3986af1f656c684e0d01a786fef1fb6ae272ec8f (diff)
downloadsrc-60b7691d56f29d848a57bfc062d41f87cce061f0.tar.gz
src-60b7691d56f29d848a57bfc062d41f87cce061f0.zip
Fix a sleepable malloc in ndastart. We shouldn't be sleeping
here. Return ENOMEM when we can't malloc a buffer for the DSM TRIM. This should fix the WITNESS warnings similar to the following: uma_zalloc_arg: zone "16" with the following non-sleepable locks held: exclusive sleep mutex CAM device lock (CAM device lock) r = 0 (0xfffff800080c34d0) locked @ /usr/src/sys/cam/nvme/nvme_da.c:351 Reviewed by: scottl@ Sponsored by: Netflix
Notes
Notes: svn path=/head/; revision=328452
Diffstat (limited to 'sys/cam/nvme/nvme_da.c')
-rw-r--r--sys/cam/nvme/nvme_da.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index 4d3dd64d946e..b120a414629d 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -897,7 +897,13 @@ ndastart(struct cam_periph *periph, union ccb *start_ccb)
struct nvme_dsm_range *dsm_range;
dsm_range =
- malloc(sizeof(*dsm_range), M_NVMEDA, M_ZERO | M_WAITOK);
+ malloc(sizeof(*dsm_range), M_NVMEDA, M_ZERO | M_NOWAIT);
+ if (dsm_range == NULL) {
+ biofinish(bp, NULL, ENOMEM);
+ xpt_release_ccb(start_ccb);
+ ndaschedule(periph);
+ return;
+ }
dsm_range->length =
bp->bio_bcount / softc->disk->d_sectorsize;
dsm_range->starting_lba =