Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3826504pxv; Mon, 28 Jun 2021 13:58:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNb0wkAuVhl+IUO7E3QsaDf668Sy2L4T43bN3y6awvD5DoiKKR2RLBauP860b/ZvRq3uxF X-Received: by 2002:a17:907:1611:: with SMTP id hb17mr25789316ejc.450.1624913919073; Mon, 28 Jun 2021 13:58:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624913919; cv=none; d=google.com; s=arc-20160816; b=LU6sOruicFNYlJj/QuTLfzuv6GTvelEJxFhh1J4N8WIMIelczTFucFtwfxT7cPcyvs rnoS2ikoPvfCzCMFsKGL3+zCyS2qmIlkDZx4f88ZF5ozC07808sF9no0js5DNW/rCOwH +nC8lyACoUPNLcTPwxPKTM2HROy+lJsFcsE6jGfJzm78CdJzpsVgutHJck8VmachzTY4 aZK4zufL88F9TfWsueKJesnyRQaGwpokqF9WG0QVH4sNV7Iw7SOA1IstoX/kRqia9OYI I6IKT2yqR4znyTWe0V47i2BTA7iDPXltlZU49nGGTrYs5SZl4BE9tfgOAMDbUf1zZpMx zp5w== 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=c145hT04T98Uh3KIvTzlo1FA9UNVG8S7xB4OMRDFqiyE7USCBxQXTAJuvQucrihoSl 4SJ/q+kqBP/Ra30Dhf7PXFVn0m6R54E+UYBrXeTbZg+Hp8XnLuwNb4o3l5+OoIAvSavD vppsluA6V9axJ1Mkbx5rN94z7gTZxRWZkCCIgYmY4zd3G2Jj0Pd6bBT9/iWCqTy13/69 IJcCsx+P/sAxZz99tty2oTEx6YlTgXJeAhSrLur9KzCCZqHDAqzGWX1Y9F2svvInxPmf C4jUpQvOpUGYf5FmmyjOXRsahqqpABwF4i6Imjw6mdPcZ2BnB5iKvo1B4EuDvtbqqvMm FFsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hSBp95Zd; 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 zp26si6504732ejb.452.2021.06.28.13.58.15; Mon, 28 Jun 2021 13:58:39 -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=hSBp95Zd; 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 S234236AbhF1PLE (ORCPT + 99 others); Mon, 28 Jun 2021 11:11:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:54440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235489AbhF1Ouw (ORCPT ); Mon, 28 Jun 2021 10:50:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D76061D2B; Mon, 28 Jun 2021 14:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1624891023; bh=mxIimWiACeddCVSoyJmIkO39lqBmr85dN1XDr12E3WA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hSBp95ZdRpqUkREfAh06qI06/m567CPrR3ApU65GKMq2RMTvCLTMgji6ODWhxzINn hSObi+BRIuETkdU3nJgwaYxT98BiDdKEB8WyC+qW7i3XbzNcuI4nXyNsJxvz7fb212 h3PVugxp/5FSGdWh5B48fqNQXBcoTOLn5/TwWMW2BMK3CuYIC8CXNdYF6bVWjcTt1V 4+d0D1LXEXQryx38q8ndM+ra5iMlzOfEnmb6BcC6HHh5VbDh57353n4yalPAwXQtgj Lf+5DKqPhkTWOeWhFGnPaDXb//5/KKSByFcoCqClCXiOd/SY4rGzeD1heDhT8Ypw+y 5192Ubck0cdag== 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.14 38/88] net: cdc_eem: fix tx fixup skb leak Date: Mon, 28 Jun 2021 10:35:38 -0400 Message-Id: <20210628143628.33342-39-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210628143628.33342-1-sashal@kernel.org> References: <20210628143628.33342-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.238-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-4.14.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 4.14.238-rc1 X-KernelTest-Deadline: 2021-06-30T14:36+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