diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2019-10-06 18:52:43 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-10-07 09:38:44 -0400 |
commit | 8211fbfaf2fe66ac4ca28bb52b4e7f61dcac0378 (patch) | |
tree | ea71d92dae01cb8a46d34ad4f6b9d94d1b1d0153 /net/core | |
parent | 328908621081c3c7455c39549c5334e74b7c525a (diff) | |
download | linux-stable-8211fbfaf2fe66ac4ca28bb52b4e7f61dcac0378.tar.gz linux-stable-8211fbfaf2fe66ac4ca28bb52b4e7f61dcac0378.tar.bz2 linux-stable-8211fbfaf2fe66ac4ca28bb52b4e7f61dcac0378.zip |
net: core: use helper skb_ensure_writable in more places
Use helper skb_ensure_writable in two more places to simplify the code.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 944de67ee95d..7d05e042c6ba 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3165,12 +3165,9 @@ int skb_checksum_help(struct sk_buff *skb) offset += skb->csum_offset; BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb)); - if (skb_cloned(skb) && - !skb_clone_writable(skb, offset + sizeof(__sum16))) { - ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); - if (ret) - goto out; - } + ret = skb_ensure_writable(skb, offset + sizeof(__sum16)); + if (ret) + goto out; *(__sum16 *)(skb->data + offset) = csum_fold(csum) ?: CSUM_MANGLED_0; out_set_summed: @@ -3205,12 +3202,11 @@ int skb_crc32c_csum_help(struct sk_buff *skb) ret = -EINVAL; goto out; } - if (skb_cloned(skb) && - !skb_clone_writable(skb, offset + sizeof(__le32))) { - ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); - if (ret) - goto out; - } + + ret = skb_ensure_writable(skb, offset + sizeof(__le32)); + if (ret) + goto out; + crc32c_csum = cpu_to_le32(~__skb_checksum(skb, start, skb->len - start, ~(__u32)0, crc32c_csum_stub)); |