From patchwork Thu Feb 14 10:24:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 158334 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp1172395jaa; Thu, 14 Feb 2019 02:25:09 -0800 (PST) X-Google-Smtp-Source: AHgI3IaSXtRdN7ZEK6OEa78Lpn/TZU7xM7jmJI6tbqDRY9x/0mEymSKQs4l4LCZcFOtHQ0B6TZDu X-Received: by 2002:a63:4913:: with SMTP id w19mr3016525pga.394.1550139909252; Thu, 14 Feb 2019 02:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550139909; cv=none; d=google.com; s=arc-20160816; b=cnBBCDKlacqz+rFi6sdQo4gSo08SG0hYK2R2/N6C6dn3hPqARrHNBm2l/vNq8uNL4H ZfqPhOHK8L0YuhJ5Dd/byYR5q/Cs/Mr+HKwn597iUrF4+JsKuEx9E3J0xNbd5Re7mj5t tS9pYeTXxkBb73rsxKjUERZH7W3MaYc7hrgVTOY8kAO6g2hiaet6OEb+rj1WnLpGttr4 jYFEbhAQlRl8+1uOQ2yeqEby0yaxKwDI1SHie9H1RW8iDBZqziqeab48710YKq+kcePp 1amQOi8AfIqFmL6/jjxMOh+mVdMs3JlbZg0Skt5FvulGyPX60CYVgEeFL2T7KKRMmkGK u8kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KEcRLbcq0VO+5Ygbms+j26kX+lJqEJ1oy6WaDYTQHxg=; b=EKRf3ioM7VwKoU5eN3Bd9yRHtOJP3zr6w0QREKhs3sLISFttIBy91bOYKGq6hp41NH lzbXb84S9t/c2iQrzEB6UtmhwSjtBsRUF97/llNJ2MMzV/vSgQ/tSaRQyAIVqQfhBo/f Y2sSnAiOW3G14KubGwan0yZKNqANHY9FkzP47E0yAT1ohtOORML0eiHA+/oJpB8AhKFG UX/Je04uhoAmHzH/MuALcQwhNSqaOE8e7gui1jyGgu0kZVHLxLkHQq6uPLXMZyLKiwNg CsONdMSEMgh94UUimbeVHI1XIN4qMIXdCj7GRSnp/k8ZTmWnCtlHBmYKNpjyisv0Ny8E MkMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=msVWzQed; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si2132062plv.258.2019.02.14.02.25.08; Thu, 14 Feb 2019 02:25:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=msVWzQed; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390202AbfBNKZI (ORCPT + 15 others); Thu, 14 Feb 2019 05:25:08 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45414 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389001AbfBNKZI (ORCPT ); Thu, 14 Feb 2019 05:25:08 -0500 Received: by mail-lf1-f65.google.com with SMTP id h10so3910805lfc.12 for ; Thu, 14 Feb 2019 02:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KEcRLbcq0VO+5Ygbms+j26kX+lJqEJ1oy6WaDYTQHxg=; b=msVWzQedOAgOiKnpj/Ur8n4ccsSLebUmbhnbnPMTLtDTzb6Q06dI4JnsNM5NvRPrj1 rPI6FL9+1eDKzAVimNZwJRPMPCWzKwqnlH+V/CSrZ3A5t1zvwKre5G2e4SISqjLoIcnt bhXtv99rpFAPQithDMDa4tqGjLSAnqDAkDHBJ9XozIATLVMgpnOQ4A1VKR+bBUSEt0B+ dQ5eyFYsJ+NOkKAiVL6rzwmOZKFH10936PwMJusmo3YVmROGXTsqvZf8Ju6IFQcspuuv EWLBMqOvO9vCqnE/9mggA+i1+eyxJ5j+bsuV5x9VV8/Ff2bAHSjXAT6pgQy8p++gff+L B+vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KEcRLbcq0VO+5Ygbms+j26kX+lJqEJ1oy6WaDYTQHxg=; b=KixDbB/hix21XrLqUw3JO82TK8GRUna0+nbt4/Gy+ugV1cQy22uNLSR4hmJJN0MDnH QO0Xjek5x2XO6iRQZdUtSWhVBYlbX+Eoqt4SkFZmxNKkMY/Bf7BtS08PLOWcbkEnGN9A hFhF13zMqRn1esZKXfi6ohcyg7ZN/6FVuu7wEs2/1QqGVRDVmJLNw+Gu4C/LcKZe30CW +7oBSO58tcsgOCe3oygjRCP8+PXI6JO5qtw6B0eTdcXlO0Qxaim1/aJckzcKEgHKSAMn b6fTcDqKXUthMYFHXNs7lDyqxpazg9NlXH/IbYHtcbodJx9PeQs8FSa/bfH/l5a2S3bD 9MEg== X-Gm-Message-State: AHQUAua6DtDpvLLwSWXVrK6FMAT8LQjo969XHLOFwcXScMq3dXZu0lis sBFdkGrxzbnBUfnsZT89rklb+Q== X-Received: by 2002:ac2:4318:: with SMTP id l24mr1748748lfh.75.1550139906327; Thu, 14 Feb 2019 02:25:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id n189sm380392lfn.82.2019.02.14.02.25.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 02:25:05 -0800 (PST) From: Linus Walleij To: Greg Kroah-Hartman , stable@vger.kernel.org, openwrt-devel@lists.openwrt.org Cc: "David S . Miller" , Eric Dumazet , Hauke Mehrtens , Dave Taht , Liping Zhang , John Youn , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , James Hughes , Felix Fietkau , Matthew Garrett Subject: [PATCH 03/10] ch9200: use skb_cow_head() to deal with cloned skbs Date: Thu, 14 Feb 2019 11:24:29 +0100 Message-Id: <20190214102436.5092-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190214102436.5092-1-linus.walleij@linaro.org> References: <20190214102436.5092-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Eric Dumazet We need to ensure there is enough headroom to push extra header, but we also need to check if we are allowed to change headers. skb_cow_head() is the proper helper to deal with this. Fixes: 4a476bd6d1d9 ("usbnet: New driver for QinHeng CH9200 devices") Signed-off-by: Eric Dumazet Cc: James Hughes Cc: Matthew Garrett Signed-off-by: David S. Miller --- drivers/net/usb/ch9200.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) -- 2.20.1 diff --git a/drivers/net/usb/ch9200.c b/drivers/net/usb/ch9200.c index 8a40202c0a17..c4f1c363e24b 100644 --- a/drivers/net/usb/ch9200.c +++ b/drivers/net/usb/ch9200.c @@ -254,14 +254,9 @@ static struct sk_buff *ch9200_tx_fixup(struct usbnet *dev, struct sk_buff *skb, tx_overhead = 0x40; len = skb->len; - if (skb_headroom(skb) < tx_overhead) { - struct sk_buff *skb2; - - skb2 = skb_copy_expand(skb, tx_overhead, 0, flags); + if (skb_cow_head(skb, tx_overhead)) { dev_kfree_skb_any(skb); - skb = skb2; - if (!skb) - return NULL; + return NULL; } __skb_push(skb, tx_overhead);