diff options
Diffstat (limited to 'net/sunrpc/xdr.c')
-rw-r--r-- | net/sunrpc/xdr.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 67b9f035ba86..f86d1baa6302 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
@@ -616,12 +616,24 @@ xdr_shift_buf(struct xdr_buf *buf, size_t len) | |||
616 | void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) | 616 | void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, uint32_t *p) |
617 | { | 617 | { |
618 | struct kvec *iov = buf->head; | 618 | struct kvec *iov = buf->head; |
619 | int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len; | ||
619 | 620 | ||
621 | BUG_ON(scratch_len < 0); | ||
620 | xdr->buf = buf; | 622 | xdr->buf = buf; |
621 | xdr->iov = iov; | 623 | xdr->iov = iov; |
622 | xdr->end = (uint32_t *)((char *)iov->iov_base + iov->iov_len); | 624 | xdr->p = (uint32_t *)((char *)iov->iov_base + iov->iov_len); |
623 | buf->len = iov->iov_len = (char *)p - (char *)iov->iov_base; | 625 | xdr->end = (uint32_t *)((char *)iov->iov_base + scratch_len); |
624 | xdr->p = p; | 626 | BUG_ON(iov->iov_len > scratch_len); |
627 | |||
628 | if (p != xdr->p && p != NULL) { | ||
629 | size_t len; | ||
630 | |||
631 | BUG_ON(p < xdr->p || p > xdr->end); | ||
632 | len = (char *)p - (char *)xdr->p; | ||
633 | xdr->p = p; | ||
634 | buf->len += len; | ||
635 | iov->iov_len += len; | ||
636 | } | ||
625 | } | 637 | } |
626 | EXPORT_SYMBOL(xdr_init_encode); | 638 | EXPORT_SYMBOL(xdr_init_encode); |
627 | 639 | ||