summaryrefslogtreecommitdiffstats
path: root/sys/dev/firewire/sbp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/firewire/sbp.c')
-rw-r--r--sys/dev/firewire/sbp.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/sys/dev/firewire/sbp.c b/sys/dev/firewire/sbp.c
index e182477..079ea74 100644
--- a/sys/dev/firewire/sbp.c
+++ b/sys/dev/firewire/sbp.c
@@ -521,13 +521,13 @@ sbp_get_text_leaf(struct fw_device *fwdev, int key, char *buf, int len)
chdr = (struct csrhdr *)&fwdev->csrrom[0];
creg = (struct csrreg *)chdr;
creg += chdr->info_len;
- for( i = chdr->info_len + 4; i <= fwdev->rommax; i+=4){
+ for( i = chdr->info_len + 4; i <= fwdev->rommax - 4; i+=4){
if((creg++)->key == key){
found = 1;
break;
}
}
- if (!found) {
+ if (!found || creg->key != CROM_TEXTLEAF) {
strncpy(buf, nullstr, len);
return;
}
@@ -780,7 +780,13 @@ END_DEBUG
static void
sbp_cam_scan_lun(struct sbp_dev *sdev)
{
- union ccb *ccb = malloc(sizeof(union ccb), M_SBP, M_ZERO);
+ union ccb *ccb;
+
+ ccb = malloc(sizeof(union ccb), M_SBP, M_NOWAIT | M_ZERO);
+ if (ccb == NULL) {
+ printf("sbp_cam_scan_lun: malloc failed\n");
+ return;
+ }
SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2);
@@ -840,9 +846,20 @@ sbp_ping_unit(struct sbp_dev *sdev)
union ccb *ccb;
struct scsi_inquiry_data *inq_buf;
- ccb = malloc(sizeof(union ccb), M_SBP, M_ZERO);
+
+ ccb = malloc(sizeof(union ccb), M_SBP, M_NOWAIT | M_ZERO);
+ if (ccb == NULL) {
+ printf("sbp_ping_unit: malloc failed\n");
+ return;
+ }
+
inq_buf = (struct scsi_inquiry_data *)
- malloc(sizeof(*inq_buf), M_SBP, 0);
+ malloc(sizeof(*inq_buf), M_SBP, M_NOWAIT);
+ if (inq_buf == NULL) {
+ free(ccb, M_SBP);
+ printf("sbp_ping_unit: malloc failed\n");
+ return;
+ }
SBP_DEBUG(0)
sbp_show_sdev_info(sdev, 2);
OpenPOWER on IntegriCloud