Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3937496pxj; Mon, 21 Jun 2021 09:45:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDQA2DgD+pu5rmpnGGDwCG8XlRDsmCYkkoLRjUO3q/r8aW+Kip5pDIOPrf7EhMzG2kid/E X-Received: by 2002:a17:907:2622:: with SMTP id aq2mr14487488ejc.48.1624293946925; Mon, 21 Jun 2021 09:45:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293946; cv=none; d=google.com; s=arc-20160816; b=HXF9R99GY24FAcIb8AUhrHOR++Ybx1bgCnGT9bCtS51Oas4wQP/qhozDPnznKd05Vn WlVS1aBaXZX15gdh+GJYm+DMC+Tm3vIYyY9Cdeh5oSQSCeFJVIzCPmGxk4vz7PwxFAuB FLkhx1DRiDL6pZmPqrgi2SuaQwugQZmdxBrh7QUh2ngSOqmA0edEhBXMYnCad2sij+HM YIEMZK234BVtztLQ7+t1Rh0wgWSo1eEYV4+Dl9WquTiPh/9fAyC3u0N5NP72hCBC14F7 slcEnBth1DUGdACtPaNd3KC/yyVlXo88KgM0iJk9hMW7sZYv91r71o+ESnwV28oSuEm5 mO5A== 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=tj2TjoRsk+AsfwI8GD1fleU53Kmc9COfftVhEB3iOfzvfhsUeQLjNW1HQsR8ldkoHx uTbtpl8405vp5MeAYWY+bxzQjSFHkBVHfX3ZZnlmC2pOjuLIPSGxMGNs226MKjWKn3fL EcNZ5FIZn+47huVhWwnVxKQURxQzwYQRM6+/5+AfcxX6fpF/wPlrulfFFyA08e42j1qT LLftXDSHaIY+zmO0+kZV6+dmCLYx4ur6+UV98r9lQ7XhAihLHAw2Uzm4BxoGFyFx6VmY 5cZrK4yUaK+yZz/Kpl+qm9x7xPIFclWBjNwAjS69Vos+YivZW0RKBqKWRHrEssPMAA3P oXHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mk7eTNDV; 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 t23si7841639ejs.286.2021.06.21.09.45.24; Mon, 21 Jun 2021 09:45:46 -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=mk7eTNDV; 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 S231147AbhFUQqn (ORCPT + 99 others); Mon, 21 Jun 2021 12:46:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:33914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232896AbhFUQlm (ORCPT ); Mon, 21 Jun 2021 12:41:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C79536134F; Mon, 21 Jun 2021 16:30:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293054; bh=eTN+BlV+f0iQcq7YZMIiD7nRsr9dem6v+4GLnTTvicY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mk7eTNDVmetE7N2rGBn2zxJ2KTDwMMOTUthainfiKE2z7mXZYIoR+4vv+hA6gCY4W lr8gg66DSoK/sRzVB3XDwW+c4jQu46U4BXlXhIiEAb9ao+Fk0JGSf78mbG/aUFXQX8 DbbaSkIzZJ3og0aC76BzpcSkzL82i7Pj3/v6VSag= 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.12 081/178] net: cdc_eem: fix tx fixup skb leak Date: Mon, 21 Jun 2021 18:14:55 +0200 Message-Id: <20210621154925.381556757@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@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