aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/xdr.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index fbbd1c475b43..08f50afd5f2a 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -730,21 +730,24 @@ static unsigned int xdr_align_pages(struct xdr_stream *xdr, unsigned int len)
730 730
731 if (xdr->nwords == 0) 731 if (xdr->nwords == 0)
732 return 0; 732 return 0;
733 if (nwords > xdr->nwords) {
734 nwords = xdr->nwords;
735 len = nwords << 2;
736 }
737 /* Realign pages to current pointer position */ 733 /* Realign pages to current pointer position */
738 iov = buf->head; 734 iov = buf->head;
739 if (iov->iov_len > cur) 735 if (iov->iov_len > cur) {
740 xdr_shrink_bufhead(buf, iov->iov_len - cur); 736 xdr_shrink_bufhead(buf, iov->iov_len - cur);
737 xdr->nwords = XDR_QUADLEN(buf->len - cur);
738 }
741 739
742 /* Truncate page data and move it into the tail */ 740 if (nwords > xdr->nwords) {
743 if (buf->page_len > len) 741 nwords = xdr->nwords;
744 xdr_shrink_pagelen(buf, buf->page_len - len); 742 len = nwords << 2;
745 else 743 }
744 if (buf->page_len <= len)
746 len = buf->page_len; 745 len = buf->page_len;
747 xdr->nwords = XDR_QUADLEN(buf->len - cur); 746 else if (nwords < xdr->nwords) {
747 /* Truncate page data and move it into the tail */
748 xdr_shrink_pagelen(buf, buf->page_len - len);
749 xdr->nwords = XDR_QUADLEN(buf->len - cur);
750 }
748 return len; 751 return len;
749} 752}
750 753