|
|
335584 |
From: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
335584 |
Date: Mon, 24 Apr 2017 17:36:34 +0530
|
|
|
335584 |
Subject: [PATCH] scsi: avoid an off-by-one error in megasas_mmio_write
|
|
|
335584 |
|
|
|
335584 |
While reading magic sequence(MFI_SEQ) in megasas_mmio_write,
|
|
|
335584 |
an off-by-one error could occur as 's->adp_reset' index is not
|
|
|
335584 |
reset after reading the last sequence.
|
|
|
335584 |
|
|
|
335584 |
Reported-by: YY Z <bigbird475958471@gmail.com>
|
|
|
335584 |
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
|
|
|
335584 |
Message-Id: <20170424120634.12268-1-ppandit@redhat.com>
|
|
|
335584 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
335584 |
(cherry picked from commit 24dfa9fa2f90a95ac33c7372de4f4f2c8a2c141f)
|
|
|
335584 |
---
|
|
|
335584 |
hw/scsi/megasas.c | 10 +++++-----
|
|
|
335584 |
1 file changed, 5 insertions(+), 5 deletions(-)
|
|
|
335584 |
|
|
|
335584 |
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
|
|
|
335584 |
index 84b8caf901..804122ab05 100644
|
|
|
335584 |
--- a/hw/scsi/megasas.c
|
|
|
335584 |
+++ b/hw/scsi/megasas.c
|
|
|
335584 |
@@ -2138,15 +2138,15 @@ static void megasas_mmio_write(void *opaque, hwaddr addr,
|
|
|
335584 |
case MFI_SEQ:
|
|
|
335584 |
trace_megasas_mmio_writel("MFI_SEQ", val);
|
|
|
335584 |
/* Magic sequence to start ADP reset */
|
|
|
335584 |
- if (adp_reset_seq[s->adp_reset] == val) {
|
|
|
335584 |
- s->adp_reset++;
|
|
|
335584 |
+ if (adp_reset_seq[s->adp_reset++] == val) {
|
|
|
335584 |
+ if (s->adp_reset == 6) {
|
|
|
335584 |
+ s->adp_reset = 0;
|
|
|
335584 |
+ s->diag = MFI_DIAG_WRITE_ENABLE;
|
|
|
335584 |
+ }
|
|
|
335584 |
} else {
|
|
|
335584 |
s->adp_reset = 0;
|
|
|
335584 |
s->diag = 0;
|
|
|
335584 |
}
|
|
|
335584 |
- if (s->adp_reset == 6) {
|
|
|
335584 |
- s->diag = MFI_DIAG_WRITE_ENABLE;
|
|
|
335584 |
- }
|
|
|
335584 |
break;
|
|
|
335584 |
case MFI_DIAG:
|
|
|
335584 |
trace_megasas_mmio_writel("MFI_DIAG", val);
|