aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-28 17:17:48 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-06-28 17:17:48 -0400
commit1537693ceaa8d6484f1ce631bec85658bfa9816c (patch)
tree9283d433f761de0af804a3d1ea9f9f3946951118 /net
parent76cacaabf15a593833d96a65a1a251002bd88178 (diff)
SUNRPC: Clean up xdr_set_iov()
Remove the 'p' argument, since that is only ever set by xdr_init_decode. Add sanity checking of 'p' inside xdr_init_decode itself. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/xdr.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 539c19fb91de..21d041cf7f65 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -554,13 +554,11 @@ void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, unsigned int b
554EXPORT_SYMBOL_GPL(xdr_write_pages); 554EXPORT_SYMBOL_GPL(xdr_write_pages);
555 555
556static void xdr_set_iov(struct xdr_stream *xdr, struct kvec *iov, 556static void xdr_set_iov(struct xdr_stream *xdr, struct kvec *iov,
557 __be32 *p, unsigned int len) 557 unsigned int len)
558{ 558{
559 if (len > iov->iov_len) 559 if (len > iov->iov_len)
560 len = iov->iov_len; 560 len = iov->iov_len;
561 if (p == NULL) 561 xdr->p = (__be32*)iov->iov_base;
562 p = (__be32*)iov->iov_base;
563 xdr->p = p;
564 xdr->end = (__be32*)(iov->iov_base + len); 562 xdr->end = (__be32*)(iov->iov_base + len);
565 xdr->iov = iov; 563 xdr->iov = iov;
566 xdr->page_ptr = NULL; 564 xdr->page_ptr = NULL;
@@ -607,7 +605,7 @@ static void xdr_set_next_page(struct xdr_stream *xdr)
607 newbase -= xdr->buf->page_base; 605 newbase -= xdr->buf->page_base;
608 606
609 if (xdr_set_page_base(xdr, newbase, PAGE_SIZE) < 0) 607 if (xdr_set_page_base(xdr, newbase, PAGE_SIZE) < 0)
610 xdr_set_iov(xdr, xdr->buf->tail, NULL, xdr->buf->len); 608 xdr_set_iov(xdr, xdr->buf->tail, xdr->buf->len);
611} 609}
612 610
613static bool xdr_set_next_buffer(struct xdr_stream *xdr) 611static bool xdr_set_next_buffer(struct xdr_stream *xdr)
@@ -616,7 +614,7 @@ static bool xdr_set_next_buffer(struct xdr_stream *xdr)
616 xdr_set_next_page(xdr); 614 xdr_set_next_page(xdr);
617 else if (xdr->iov == xdr->buf->head) { 615 else if (xdr->iov == xdr->buf->head) {
618 if (xdr_set_page_base(xdr, 0, PAGE_SIZE) < 0) 616 if (xdr_set_page_base(xdr, 0, PAGE_SIZE) < 0)
619 xdr_set_iov(xdr, xdr->buf->tail, NULL, xdr->buf->len); 617 xdr_set_iov(xdr, xdr->buf->tail, xdr->buf->len);
620 } 618 }
621 return xdr->p != xdr->end; 619 return xdr->p != xdr->end;
622} 620}
@@ -633,9 +631,11 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
633 xdr->scratch.iov_base = NULL; 631 xdr->scratch.iov_base = NULL;
634 xdr->scratch.iov_len = 0; 632 xdr->scratch.iov_len = 0;
635 if (buf->head[0].iov_len != 0) 633 if (buf->head[0].iov_len != 0)
636 xdr_set_iov(xdr, buf->head, p, buf->len); 634 xdr_set_iov(xdr, buf->head, buf->len);
637 else if (buf->page_len != 0) 635 else if (buf->page_len != 0)
638 xdr_set_page_base(xdr, 0, buf->len); 636 xdr_set_page_base(xdr, 0, buf->len);
637 if (p != NULL && p > xdr->p && xdr->end >= p)
638 xdr->p = p;
639} 639}
640EXPORT_SYMBOL_GPL(xdr_init_decode); 640EXPORT_SYMBOL_GPL(xdr_init_decode);
641 641