Skip to content

Commit 1537693

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
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>
1 parent 76cacaa commit 1537693

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎net/sunrpc/xdr.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,13 +554,11 @@ void xdr_write_pages(struct xdr_stream *xdr, struct page **pages, unsigned int b
554554
EXPORT_SYMBOL_GPL(xdr_write_pages);
555555

556556
static void xdr_set_iov(struct xdr_stream *xdr, struct kvec *iov,
557-
__be32 *p, unsigned int len)
557+
unsigned int len)
558558
{
559559
if (len > iov->iov_len)
560560
len = iov->iov_len;
561-
if (p == NULL)
562-
p = (__be32*)iov->iov_base;
563-
xdr->p = p;
561+
xdr->p = (__be32*)iov->iov_base;
564562
xdr->end = (__be32*)(iov->iov_base + len);
565563
xdr->iov = iov;
566564
xdr->page_ptr = NULL;
@@ -607,7 +605,7 @@ static void xdr_set_next_page(struct xdr_stream *xdr)
607605
newbase -= xdr->buf->page_base;
608606

609607
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);
611609
}
612610

613611
static bool xdr_set_next_buffer(struct xdr_stream *xdr)
@@ -616,7 +614,7 @@ static bool xdr_set_next_buffer(struct xdr_stream *xdr)
616614
xdr_set_next_page(xdr);
617615
else if (xdr->iov == xdr->buf->head) {
618616
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);
620618
}
621619
return xdr->p != xdr->end;
622620
}
@@ -633,9 +631,11 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
633631
xdr->scratch.iov_base = NULL;
634632
xdr->scratch.iov_len = 0;
635633
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);
637635
else if (buf->page_len != 0)
638636
xdr_set_page_base(xdr, 0, buf->len);
637+
if (p != NULL && p > xdr->p && xdr->end >= p)
638+
xdr->p = p;
639639
}
640640
EXPORT_SYMBOL_GPL(xdr_init_decode);
641641

0 commit comments

Comments
 (0)