diff options
Diffstat (limited to 'drivers/infiniband/hw/hfi1/pio_copy.c')
-rw-r--r-- | drivers/infiniband/hw/hfi1/pio_copy.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/hfi1/pio_copy.c b/drivers/infiniband/hw/hfi1/pio_copy.c index 8c25e1b58849..3a1ef3056282 100644 --- a/drivers/infiniband/hw/hfi1/pio_copy.c +++ b/drivers/infiniband/hw/hfi1/pio_copy.c | |||
@@ -771,6 +771,9 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes) | |||
771 | read_extra_bytes(pbuf, from, to_fill); | 771 | read_extra_bytes(pbuf, from, to_fill); |
772 | from += to_fill; | 772 | from += to_fill; |
773 | nbytes -= to_fill; | 773 | nbytes -= to_fill; |
774 | /* may not be enough valid bytes left to align */ | ||
775 | if (extra > nbytes) | ||
776 | extra = nbytes; | ||
774 | 777 | ||
775 | /* ...now write carry */ | 778 | /* ...now write carry */ |
776 | dest = pbuf->start + (pbuf->qw_written * sizeof(u64)); | 779 | dest = pbuf->start + (pbuf->qw_written * sizeof(u64)); |
@@ -798,6 +801,15 @@ void seg_pio_copy_mid(struct pio_buf *pbuf, const void *from, size_t nbytes) | |||
798 | read_low_bytes(pbuf, from, extra); | 801 | read_low_bytes(pbuf, from, extra); |
799 | from += extra; | 802 | from += extra; |
800 | nbytes -= extra; | 803 | nbytes -= extra; |
804 | /* | ||
805 | * If no bytes are left, return early - we are done. | ||
806 | * NOTE: This short-circuit is *required* because | ||
807 | * "extra" may have been reduced in size and "from" | ||
808 | * is not aligned, as required when leaving this | ||
809 | * if block. | ||
810 | */ | ||
811 | if (nbytes == 0) | ||
812 | return; | ||
801 | } | 813 | } |
802 | 814 | ||
803 | /* at this point, from is QW aligned */ | 815 | /* at this point, from is QW aligned */ |