summaryrefslogtreecommitdiffstats
path: root/sys/cam/scsi/scsi_sa.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cam/scsi/scsi_sa.c')
-rw-r--r--sys/cam/scsi/scsi_sa.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index 354ff13..83c670f 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -4464,7 +4464,18 @@ saextget(struct cdev *dev, struct cam_periph *periph, struct sbuf *sb,
if (cgd.serial_num_len > sizeof(tmpstr)) {
ts2_len = cgd.serial_num_len + 1;
ts2_malloc = 1;
- tmpstr2 = malloc(ts2_len, M_SCSISA, M_WAITOK | M_ZERO);
+ tmpstr2 = malloc(ts2_len, M_SCSISA, M_NOWAIT | M_ZERO);
+ /*
+ * The 80 characters allocated on the stack above
+ * will handle the vast majority of serial numbers.
+ * If we run into one that is larger than that, and
+ * we can't malloc the length without blocking,
+ * bail out with an out of memory error.
+ */
+ if (tmpstr2 == NULL) {
+ error = ENOMEM;
+ goto extget_bailout;
+ }
} else {
ts2_len = sizeof(tmpstr);
ts2_malloc = 0;
OpenPOWER on IntegriCloud