Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3861709pxv; Mon, 28 Jun 2021 15:01:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMp2NlBLARg6J6+sLllEHuH3D4LGCfTbVLHa0ctQDUPNtDzdlBX3EIqzbkPbd+fN1X1kJe X-Received: by 2002:a50:ccd8:: with SMTP id b24mr35922712edj.386.1624917688598; Mon, 28 Jun 2021 15:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624917688; cv=none; d=google.com; s=arc-20160816; b=pdKWKfizrvCAsHhlLnpzxFx2xHAlSHDbv8W9BRtdtAE8xjuv96p2Z0spgNAqgIHeSZ NXM5/6D7Cw5Rj24l/XTiQtqyblurafLmBYPXmRZu0LtRAGjTlE67UJxLLjKx4k1G8x1l rWaNBuI9M+Bf2/thGUrkaXrqNsCM0rXqzBYympZf4rfmNoxQDHXQ1lMjwtPmcN/kDeQH heG/vAWezL5H0xoUTjnzkD0hICjAMcRfShGXuO83gaQR0EmR46bdxAG7XixiwYrLYeG6 VBSrjHkUabxjkvAuByVTB+SikoBo2ADYW0HPjijeTGnswtPOmNKJVrxITtXStPjXQVjT ydew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zGg22u1LcIBbuGORekBWB0IeoURRrFfEuUezfDdLglg=; b=tdo//qy/hUDa9DKTBSWgBF3QnMaytr9ekja1MbQ6HhqJOrQFGY45iUKSfDOma3Zywf 5FD5LXYKT7D9syLWgbBkQAqg9NSWGVmMkU6zt9+RNUemnLlUltLS4H6af5iFzE/m1yxg 7piCBqsyx40N+5du6ic2e05iiyDKME6u+rcdg/pGNoN8ffaNBBh59L8V+Hpb+eYJMpoR ZIkNMqgLkun4X3CtUkzqDNsg80ynZeXSOJN2aHvJpWvrr8y2KQ19lSKdh3fq3hMDFdFp wL1QfsstdBM8bWQmrpxaNUYv5DbpIZc3kruMBPgL98a5EwzQVv/n0yyzqFOI5q8Fzpxa ilCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b7+kr7Xr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si15128500ejc.505.2021.06.28.15.01.03; Mon, 28 Jun 2021 15:01:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b7+kr7Xr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238457AbhF1PVb (ORCPT + 99 others); Mon, 28 Jun 2021 11:21:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:36482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235291AbhF1O6b (ORCPT ); Mon, 28 Jun 2021 10:58:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 41FF661D55; Mon, 28 Jun 2021 14:40:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891234; bh=mxIimWiACeddCVSoyJmIkO39lqBmr85dN1XDr12E3WA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b7+kr7Xrh7bjBGen7koTe/U+W8p33P9m+HX2VryUMjSoF+XSYe0rPVNFn6X7ZOeNv moG4qc56TdJEPNfGcKEcQpu3X05iF2OXKBlSKbgFPqkygPcuh0pJ1nT4UaPTUiFIUX FPx5WfahjUefHFDgsHCvptqEtjXfW9tHD1x0gwxTTPF5SIZyKX4jk2jwszX/CFkNOW cNHJixoswJq3yHNKWx6t+Z/xOe1mGHimd9J6UGVZR5czMakpNrc4bYIlvbM7Zk9NOU hXAEc1RMk7RIt260TXSoBLAXk2Fb03c5fMz9/hgkfpM0WdBZGdnfAnj0iZHs9Vph2z WL7SGmRIyodFg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linyu Yuan , Greg Kroah-Hartman , "David S . Miller" , Sasha Levin Subject: [PATCH 4.9 34/71] net: cdc_eem: fix tx fixup skb leak Date: Mon, 28 Jun 2021 10:39:26 -0400 Message-Id: <20210628144003.34260-35-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628144003.34260-1-sashal@kernel.org> References: <20210628144003.34260-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.274-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.9.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.9.274-rc1 X-KernelTest-Deadline: 2021-06-30T14:39+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linyu Yuan [ Upstream commit c3b26fdf1b32f91c7a3bc743384b4a298ab53ad7 ] when usbnet transmit a skb, eem fixup it in eem_tx_fixup(), if skb_copy_expand() failed, it return NULL, usbnet_start_xmit() will have no chance to free original skb. fix it by free orginal skb in eem_tx_fixup() first, then check skb clone status, if failed, return NULL to usbnet. Fixes: 9f722c0978b0 ("usbnet: CDC EEM support (v5)") Signed-off-by: Linyu Yuan Reviewed-by: Greg Kroah-Hartman Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/usb/cdc_eem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c index f7180f8db39e..9c15e1a1261b 100644 --- a/drivers/net/usb/cdc_eem.c +++ b/drivers/net/usb/cdc_eem.c @@ -138,10 +138,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, } skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); + dev_kfree_skb_any(skb); if (!skb2) return NULL; - dev_kfree_skb_any(skb); skb = skb2; done: -- 2.30.2