diff mbox

[1/2] linux-generic: buffers: correct segment length calculation for packets

Message ID 1435268892-22935-1-git-send-email-bill.fischofer@linaro.org
State Accepted
Commit 828f2e54799dd6f0f277aa125fbb325f48da9362
Headers show

Commit Message

Bill Fischofer June 25, 2015, 9:48 p.m. UTC
Fix for Bug https://bugs.linaro.org/show_bug.cgi?id=1661

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
---
 platform/linux-generic/include/odp_buffer_inlines.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Maxim Uvarov July 1, 2015, 11:47 a.m. UTC | #1
Merged,

Thanks,
Maxim.

On 06/26/15 00:48, Bill Fischofer wrote:
> Fix for Bug https://bugs.linaro.org/show_bug.cgi?id=1661
>
> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>
> ---
>   platform/linux-generic/include/odp_buffer_inlines.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h
> index 91e56bd..74af38b 100644
> --- a/platform/linux-generic/include/odp_buffer_inlines.h
> +++ b/platform/linux-generic/include/odp_buffer_inlines.h
> @@ -182,7 +182,9 @@ static inline void *segment_map(odp_buffer_hdr_t *buf,
>   	/* Set seglen if caller is asking for it */
>   	if (seglen != NULL) {
>   		buf_left = limit - seg_offset;
> -		*seglen = buf_left < buf->segsize ? buf_left : buf->segsize;
> +		*seglen = buf_left < buf->segsize ? buf_left :
> +			(seg_offset >= buf->segsize ? buf->segsize :
> +			 buf->segsize - seg_offset);
>   	}
>   
>   	return (void *)seg_addr;
diff mbox

Patch

diff --git a/platform/linux-generic/include/odp_buffer_inlines.h b/platform/linux-generic/include/odp_buffer_inlines.h
index 91e56bd..74af38b 100644
--- a/platform/linux-generic/include/odp_buffer_inlines.h
+++ b/platform/linux-generic/include/odp_buffer_inlines.h
@@ -182,7 +182,9 @@  static inline void *segment_map(odp_buffer_hdr_t *buf,
 	/* Set seglen if caller is asking for it */
 	if (seglen != NULL) {
 		buf_left = limit - seg_offset;
-		*seglen = buf_left < buf->segsize ? buf_left : buf->segsize;
+		*seglen = buf_left < buf->segsize ? buf_left :
+			(seg_offset >= buf->segsize ? buf->segsize :
+			 buf->segsize - seg_offset);
 	}
 
 	return (void *)seg_addr;