diff options
author | Jann Horn <jannh@google.com> | 2019-02-14 16:35:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-02-17 14:01:17 -0500 |
commit | 1eb00162f86abda9535de5cbaf6e168f7747ee90 (patch) | |
tree | 7e3fa360da5809be081b1e454461204514e7d355 | |
parent | 6a79507cfe94c7729207659501ff88914b3eb198 (diff) |
net: caif: use skb helpers instead of open-coding them
Use existing skb_put_data() and skb_trim() instead of open-coding them,
with the skb_put_data() first so that logically, `skb` still contains the
data to be copied in its data..tail area when skb_put_data() reads it.
This change on its own is a cleanup, and it is also necessary for potential
future integration of skbuffs with things like KASAN.
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/caif/cfpkt_skbuff.c | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c index 38c2b7a890dd..37ac5ca0ffdf 100644 --- a/net/caif/cfpkt_skbuff.c +++ b/net/caif/cfpkt_skbuff.c | |||
@@ -319,16 +319,12 @@ struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, | |||
319 | if (tmppkt == NULL) | 319 | if (tmppkt == NULL) |
320 | return NULL; | 320 | return NULL; |
321 | tmp = pkt_to_skb(tmppkt); | 321 | tmp = pkt_to_skb(tmppkt); |
322 | skb_set_tail_pointer(tmp, dstlen); | 322 | skb_put_data(tmp, dst->data, dstlen); |
323 | tmp->len = dstlen; | ||
324 | memcpy(tmp->data, dst->data, dstlen); | ||
325 | cfpkt_destroy(dstpkt); | 323 | cfpkt_destroy(dstpkt); |
326 | dst = tmp; | 324 | dst = tmp; |
327 | } | 325 | } |
328 | memcpy(skb_tail_pointer(dst), add->data, skb_headlen(add)); | 326 | skb_put_data(dst, add->data, skb_headlen(add)); |
329 | cfpkt_destroy(addpkt); | 327 | cfpkt_destroy(addpkt); |
330 | dst->tail += addlen; | ||
331 | dst->len += addlen; | ||
332 | return skb_to_pkt(dst); | 328 | return skb_to_pkt(dst); |
333 | } | 329 | } |
334 | 330 | ||
@@ -359,13 +355,11 @@ struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos) | |||
359 | if (skb2 == NULL) | 355 | if (skb2 == NULL) |
360 | return NULL; | 356 | return NULL; |
361 | 357 | ||
358 | skb_put_data(skb2, split, len2nd); | ||
359 | |||
362 | /* Reduce the length of the original packet */ | 360 | /* Reduce the length of the original packet */ |
363 | skb_set_tail_pointer(skb, pos); | 361 | skb_trim(skb, pos); |
364 | skb->len = pos; | ||
365 | 362 | ||
366 | memcpy(skb2->data, split, len2nd); | ||
367 | skb2->tail += len2nd; | ||
368 | skb2->len += len2nd; | ||
369 | skb2->priority = skb->priority; | 363 | skb2->priority = skb->priority; |
370 | return skb_to_pkt(skb2); | 364 | return skb_to_pkt(skb2); |
371 | } | 365 | } |