summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/arcmsr
diff options
context:
space:
mode:
authorching Huang <ching2048@areca.com.tw>2023-03-23 01:20:35 +0800
committerMartin K. Petersen <martin.petersen@oracle.com>2023-03-24 17:54:24 -0400
commit3e40814818cee1b564962786f867fb71bb754686 (patch)
tree533120f7eb6410b4bc88702de536a89ba116aade /drivers/scsi/arcmsr
parentc3e9b937fb817ca36610dc10677cb1442aa07e72 (diff)
downloadlinux-3e40814818cee1b564962786f867fb71bb754686.tar.gz
linux-3e40814818cee1b564962786f867fb71bb754686.tar.bz2
linux-3e40814818cee1b564962786f867fb71bb754686.zip
scsi: arcmsr: Fix reading empty buffer length
Fix empty buffer length error which causes ARECA CLI app command timeout. Signed-off-by: ching Huang <ching2048@areca.com.tw> Link: https://lore.kernel.org/r/4aec4385abc6eab10b575c28130ec615a144492d.camel@areca.com.tw Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/arcmsr')
-rw-r--r--drivers/scsi/arcmsr/arcmsr_hba.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index ce92d4281da6..f97936d66a6a 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -2255,8 +2255,11 @@ static void arcmsr_iop2drv_data_wrote_handle(struct AdapterControlBlock *acb)
spin_lock_irqsave(&acb->rqbuffer_lock, flags);
prbuffer = arcmsr_get_iop_rqbuffer(acb);
- buf_empty_len = (acb->rqbuf_putIndex - acb->rqbuf_getIndex - 1) &
- (ARCMSR_MAX_QBUFFER - 1);
+ if (acb->rqbuf_putIndex >= acb->rqbuf_getIndex) {
+ buf_empty_len = (ARCMSR_MAX_QBUFFER - 1) -
+ (acb->rqbuf_putIndex - acb->rqbuf_getIndex);
+ } else
+ buf_empty_len = acb->rqbuf_getIndex - acb->rqbuf_putIndex - 1;
if (buf_empty_len >= readl(&prbuffer->data_len)) {
if (arcmsr_Read_iop_rqbuffer_data(acb, prbuffer) == 0)
acb->acb_flags |= ACB_F_IOPDATA_OVERFLOW;