On Wed, Apr 20, 2016 at 03:17:41AM -0700, Sowmini Varadhan wrote:
...
> +/* Extract to_copy bytes starting at off from skb, and return this in
> + * a new skb
> + */
> +struct sk_buff *pskb_extract(struct sk_buff *skb, int off,
> +                          int to_copy, gfp_t gfp)
> +{
> +     struct sk_buff  *clone = skb_clone(skb, gfp);
> +
> +     if (!clone)
> +             return NULL;
> +
> +     if (pskb_carve(clone, off, gfp) < 0) {
> +             pr_warn("pskb_carve failed\n");

You most likely don't want these pr_warn

> +             kfree_skb(clone);
> +             return NULL;
> +     }
> +
> +     if (pskb_trim(clone, to_copy)) {
> +             pr_warn("pskb_trim failed\n");
> +             kfree_skb(clone);
> +             return NULL;
> +     }
> +     return clone;

Then these two blocks can be just:

        if (pskb_carve(clone, off, gfp) < 0 ||
            pskb_trim(clone, to_copy)) {
                kfree_skb(clone);
                clone = NULL;
        }
        return clone;

  Marcelo

> +}
> +EXPORT_SYMBOL(pskb_extract);
> -- 
> 1.7.1
> 

Reply via email to