From bc691a9d86e0ef6f2043582d0861b14658599fe3 Mon Sep 17 00:00:00 2001 From: joevt Date: Mon, 22 Apr 2024 00:27:41 -0700 Subject: [PATCH] scsibus: Check for invalid target_id. --- devices/common/scsi/scsibus.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/devices/common/scsi/scsibus.cpp b/devices/common/scsi/scsibus.cpp index 1703af3..cc56337 100644 --- a/devices/common/scsi/scsibus.cpp +++ b/devices/common/scsi/scsibus.cpp @@ -286,12 +286,22 @@ int ScsiBus::target_xfer_data() { void ScsiBus::target_next_step() { - this->devices[this->target_id]->next_step(); + if (target_id < 0) { + LOG_F(ERROR, "%s: target_id is not set yet.", this->get_name().c_str()); + } + else { + this->devices[this->target_id]->next_step(); + } } bool ScsiBus::negotiate_xfer(int& bytes_in, int& bytes_out) { - this->devices[this->target_id]->prepare_xfer(this, bytes_in, bytes_out); + if (target_id < 0) { + LOG_F(ERROR, "%s: target_id is not set yet.", this->get_name().c_str()); + } + else { + this->devices[this->target_id]->prepare_xfer(this, bytes_in, bytes_out); + } return true; }