diff options
-rw-r--r-- | net/sunrpc/xdr.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 3317db3cb102..3bbef7f5f826 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c | |||
@@ -396,12 +396,21 @@ xdr_shrink_pagelen(struct xdr_buf *buf, size_t len) | |||
396 | struct kvec *tail; | 396 | struct kvec *tail; |
397 | size_t copy; | 397 | size_t copy; |
398 | unsigned int pglen = buf->page_len; | 398 | unsigned int pglen = buf->page_len; |
399 | unsigned int tailbuf_len; | ||
399 | 400 | ||
400 | tail = buf->tail; | 401 | tail = buf->tail; |
401 | BUG_ON (len > pglen); | 402 | BUG_ON (len > pglen); |
402 | 403 | ||
404 | tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len; | ||
405 | |||
403 | /* Shift the tail first */ | 406 | /* Shift the tail first */ |
404 | if (tail->iov_len != 0) { | 407 | if (tailbuf_len != 0) { |
408 | unsigned int free_space = tailbuf_len - tail->iov_len; | ||
409 | |||
410 | if (len < free_space) | ||
411 | free_space = len; | ||
412 | tail->iov_len += free_space; | ||
413 | |||
405 | copy = len; | 414 | copy = len; |
406 | if (tail->iov_len > len) { | 415 | if (tail->iov_len > len) { |
407 | char *p = (char *)tail->iov_base + len; | 416 | char *p = (char *)tail->iov_base + len; |