Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ax25: use skb_expand_head

Use skb_expand_head() in ax25_transmit_buffer and ax25_rt_build_path.
Unlike skb_realloc_headroom, new helper does not allocate a new skb if possible.

Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vasily Averin and committed by
David S. Miller
53744a4a 14ee70ca

+7 -23
+1 -3
net/ax25/ax25_ip.c
··· 193 193 skb_pull(skb, AX25_KISS_HEADER_LEN); 194 194 195 195 if (digipeat != NULL) { 196 - if ((ourskb = ax25_rt_build_path(skb, src, dst, route->digipeat)) == NULL) { 197 - kfree_skb(skb); 196 + if ((ourskb = ax25_rt_build_path(skb, src, dst, route->digipeat)) == NULL) 198 197 goto put; 199 - } 200 198 201 199 skb = ourskb; 202 200 }
+3 -10
net/ax25/ax25_out.c
··· 325 325 326 326 void ax25_transmit_buffer(ax25_cb *ax25, struct sk_buff *skb, int type) 327 327 { 328 - struct sk_buff *skbn; 329 328 unsigned char *ptr; 330 329 int headroom; 331 330 ··· 335 336 336 337 headroom = ax25_addr_size(ax25->digipeat); 337 338 338 - if (skb_headroom(skb) < headroom) { 339 - if ((skbn = skb_realloc_headroom(skb, headroom)) == NULL) { 339 + if (unlikely(skb_headroom(skb) < headroom)) { 340 + skb = skb_expand_head(skb, headroom); 341 + if (!skb) { 340 342 printk(KERN_CRIT "AX.25: ax25_transmit_buffer - out of memory\n"); 341 - kfree_skb(skb); 342 343 return; 343 344 } 344 - 345 - if (skb->sk != NULL) 346 - skb_set_owner_w(skbn, skb->sk); 347 - 348 - consume_skb(skb); 349 - skb = skbn; 350 345 } 351 346 352 347 ptr = skb_push(skb, headroom);
+3 -10
net/ax25/ax25_route.c
··· 441 441 struct sk_buff *ax25_rt_build_path(struct sk_buff *skb, ax25_address *src, 442 442 ax25_address *dest, ax25_digi *digi) 443 443 { 444 - struct sk_buff *skbn; 445 444 unsigned char *bp; 446 445 int len; 447 446 448 447 len = digi->ndigi * AX25_ADDR_LEN; 449 448 450 - if (skb_headroom(skb) < len) { 451 - if ((skbn = skb_realloc_headroom(skb, len)) == NULL) { 449 + if (unlikely(skb_headroom(skb) < len)) { 450 + skb = skb_expand_head(skb, len); 451 + if (!skb) { 452 452 printk(KERN_CRIT "AX.25: ax25_dg_build_path - out of memory\n"); 453 453 return NULL; 454 454 } 455 - 456 - if (skb->sk != NULL) 457 - skb_set_owner_w(skbn, skb->sk); 458 - 459 - consume_skb(skb); 460 - 461 - skb = skbn; 462 455 } 463 456 464 457 bp = skb_push(skb, len);