Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3921304pxj; Mon, 21 Jun 2021 09:24:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6I6bcwOh7X+EOeeX3DlMqCtggLEU7w5/GtOuScrCU2qCeUzAp8onoKIIHr9b/Sk0PXWf8 X-Received: by 2002:a50:f68d:: with SMTP id d13mr22837691edn.318.1624292692638; Mon, 21 Jun 2021 09:24:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292692; cv=none; d=google.com; s=arc-20160816; b=iIO7jR5yx3dlXOGhZZkvmUDxzKjAeNB4alGRauBopr0g2/MzERZ4eNFukYG/bLUVBz 6wd7BKplI75Z8HFR+FfTP9g4nDofQTFthGmw6dWEvoACvFUOb9rpOlUEWy/z5nXImnkc n3MzKrLs1TRF3BhmqrVSTBS1OmKkSRVR81Riw27a0lt8AVfUZYk0TJiBYBxDMCzJkFhy SS19r3co6K5XK8DWh0IVex1HkEa6Rc38Fodog++p81zrFJCxj/Hr/gjwWsWFB7ZlA+JG 9ehgxHS6eUPsFsBSVprrflxZ+MJSH30MZS9maf6UKZrdiAdabo+32CFZdXINDdIx84ZH 3LaA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2Kr0YJpk4e/0mzk57zndX+qAweo+A9OnnZWeyL4bILI=; b=kkENq25VU4f1uFTODuF32QVSIP1VOrMmbL1HCbFoUaLzkGXVf8ansAD3agcnCZHm51 j/GWvkYkgvw3plw4k6uGHSzMNkmlj7P3jgb4ylgxRCNSikIEBkFfUZQBDy6K0JHdvtHL HZFUQI0K/DGg+yIkw7Fxh8OeOR3hFPHLmjPHMbu8957wQVuAGD9F6gjjPHWMrsidKvQ5 k9WngxVUDQKBVn4mtGf5xJh1gmjEPAyosuDtfiumG00KshOPsEd8+eTH89vOamycA5qM 2kCfj9fwbqLY5rnZ2k7NCgo3INpCVBp4w8u/vStIhUU1ATkR++hVqubXL3JqEWhXKE8X MmfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ryRoHM3g; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ds7si9545546ejc.304.2021.06.21.09.24.30; Mon, 21 Jun 2021 09:24:52 -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=@linuxfoundation.org header.s=korg header.b=ryRoHM3g; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230357AbhFUQXC (ORCPT + 99 others); Mon, 21 Jun 2021 12:23:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:41712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231815AbhFUQVr (ORCPT ); Mon, 21 Jun 2021 12:21:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91A166120D; Mon, 21 Jun 2021 16:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292366; bh=eTN+BlV+f0iQcq7YZMIiD7nRsr9dem6v+4GLnTTvicY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ryRoHM3gE4uuYKU4ZyJGxxHQN9Y5V8K+nGpLln0pc6oQEt5tBoxd9B65lxZSAfygB jJ6jac6RJBjE/oPqTTHBrO40vM4uNz9SO+4Z2eZLk+WOnSzpfNJua1NbsDisJJkdD+ TPPlSVuQYYufi8FTewZye700K/WeWD+PXrCsuvzE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linyu Yuan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 37/90] net: cdc_eem: fix tx fixup skb leak Date: Mon, 21 Jun 2021 18:15:12 +0200 Message-Id: <20210621154905.379031652@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 0eeec80bec31..e4a570366646 100644 --- a/drivers/net/usb/cdc_eem.c +++ b/drivers/net/usb/cdc_eem.c @@ -123,10 +123,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