]>
Commit | Line | Data |
---|---|---|
e74c0f31 | 1 | From c442fb4a11d8dc527c90bf90a1fd1b15646f4c57 Mon Sep 17 00:00:00 2001 |
90a6d957 WB |
2 | From: Prasad J Pandit <pjp@fedoraproject.org> |
3 | Date: Mon, 24 Apr 2017 17:36:34 +0530 | |
e74c0f31 | 4 | Subject: [PATCH 14/23] scsi: avoid an off-by-one error in megasas_mmio_write |
90a6d957 WB |
5 | |
6 | While reading magic sequence(MFI_SEQ) in megasas_mmio_write, | |
7 | an off-by-one error could occur as 's->adp_reset' index is not | |
8 | reset after reading the last sequence. | |
9 | ||
10 | Reported-by: YY Z <bigbird475958471@gmail.com> | |
11 | Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org> | |
12 | Message-Id: <20170424120634.12268-1-ppandit@redhat.com> | |
13 | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> | |
14 | --- | |
15 | hw/scsi/megasas.c | 10 +++++----- | |
16 | 1 file changed, 5 insertions(+), 5 deletions(-) | |
17 | ||
18 | diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c | |
19 | index 84b8caf901..804122ab05 100644 | |
20 | --- a/hw/scsi/megasas.c | |
21 | +++ b/hw/scsi/megasas.c | |
22 | @@ -2138,15 +2138,15 @@ static void megasas_mmio_write(void *opaque, hwaddr addr, | |
23 | case MFI_SEQ: | |
24 | trace_megasas_mmio_writel("MFI_SEQ", val); | |
25 | /* Magic sequence to start ADP reset */ | |
26 | - if (adp_reset_seq[s->adp_reset] == val) { | |
27 | - s->adp_reset++; | |
28 | + if (adp_reset_seq[s->adp_reset++] == val) { | |
29 | + if (s->adp_reset == 6) { | |
30 | + s->adp_reset = 0; | |
31 | + s->diag = MFI_DIAG_WRITE_ENABLE; | |
32 | + } | |
33 | } else { | |
34 | s->adp_reset = 0; | |
35 | s->diag = 0; | |
36 | } | |
37 | - if (s->adp_reset == 6) { | |
38 | - s->diag = MFI_DIAG_WRITE_ENABLE; | |
39 | - } | |
40 | break; | |
41 | case MFI_DIAG: | |
42 | trace_megasas_mmio_writel("MFI_DIAG", val); | |
43 | -- | |
44 | 2.11.0 | |
45 |