[Qemu-devel] [PATCH] scsi: mptsas: fix the wrong reading size in fetch request

Li Qiang posted 1 patch 7 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1489488980-130668-1-git-send-email-liqiang6-s@360.cn
Test checkpatch passed
Test docker passed
hw/scsi/mptsas.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[Qemu-devel] [PATCH] scsi: mptsas: fix the wrong reading size in fetch request
Posted by Li Qiang 7 years, 1 month ago
When fetching request, it should read sizeof(*hdr), not the
pointer hdr.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
---
 hw/scsi/mptsas.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
index 2e091c0..765ab53 100644
--- a/hw/scsi/mptsas.c
+++ b/hw/scsi/mptsas.c
@@ -756,7 +756,7 @@ static void mptsas_fetch_request(MPTSASState *s)
 
     /* Read the message header from the guest first. */
     addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post);
-    pci_dma_read(pci, addr, req, sizeof(hdr));
+    pci_dma_read(pci, addr, req, sizeof(*hdr));
 
     if (hdr->Function < ARRAY_SIZE(mpi_request_sizes) &&
         mpi_request_sizes[hdr->Function]) {
@@ -766,8 +766,8 @@ static void mptsas_fetch_request(MPTSASState *s)
          */
         size = mpi_request_sizes[hdr->Function];
         assert(size <= MPTSAS_MAX_REQUEST_SIZE);
-        pci_dma_read(pci, addr + sizeof(hdr), &req[sizeof(hdr)],
-                     size - sizeof(hdr));
+        pci_dma_read(pci, addr + sizeof(*hdr), &req[sizeof(*hdr)],
+                     size - sizeof(*hdr));
     }
 
     if (hdr->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
-- 
2.7.4


Re: [Qemu-devel] [PATCH] scsi: mptsas: fix the wrong reading size in fetch request
Posted by Paolo Bonzini 7 years, 1 month ago

On 14/03/2017 11:56, Li Qiang wrote:
> When fetching request, it should read sizeof(*hdr), not the
> pointer hdr.
> 
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
> ---
>  hw/scsi/mptsas.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi/mptsas.c b/hw/scsi/mptsas.c
> index 2e091c0..765ab53 100644
> --- a/hw/scsi/mptsas.c
> +++ b/hw/scsi/mptsas.c
> @@ -756,7 +756,7 @@ static void mptsas_fetch_request(MPTSASState *s)
>  
>      /* Read the message header from the guest first. */
>      addr = s->host_mfa_high_addr | MPTSAS_FIFO_GET(s, request_post);
> -    pci_dma_read(pci, addr, req, sizeof(hdr));
> +    pci_dma_read(pci, addr, req, sizeof(*hdr));
>  
>      if (hdr->Function < ARRAY_SIZE(mpi_request_sizes) &&
>          mpi_request_sizes[hdr->Function]) {
> @@ -766,8 +766,8 @@ static void mptsas_fetch_request(MPTSASState *s)
>           */
>          size = mpi_request_sizes[hdr->Function];
>          assert(size <= MPTSAS_MAX_REQUEST_SIZE);
> -        pci_dma_read(pci, addr + sizeof(hdr), &req[sizeof(hdr)],
> -                     size - sizeof(hdr));
> +        pci_dma_read(pci, addr + sizeof(*hdr), &req[sizeof(*hdr)],
> +                     size - sizeof(*hdr));
>      }
>  
>      if (hdr->Function == MPI_FUNCTION_SCSI_IO_REQUEST) {
> 

Cc: qemu-stable@nongnu.org

Queued for 2.9, thanks.

Paolo