Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3323875pxf; Mon, 15 Mar 2021 07:09:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWYa2ahnifaAJRdxfocuS4Yw/lvE4bvPL+Yz0ceQOfLjxzAhHTQI0KaAfXCgNIx14vg/86 X-Received: by 2002:a17:907:2d24:: with SMTP id gs36mr23869360ejc.344.1615817339729; Mon, 15 Mar 2021 07:08:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817339; cv=none; d=google.com; s=arc-20160816; b=vnGfAKAgkuX8Vo5JrZE1430MjFVAr32G5LAtQOSz/k/d8DoJgEvlj3TymlXeQhtsHa UIqMfECTmHRFMxF86f2LATmgGAQqqFPOXxp6WteHLjoxLsapnlX1i1r3kRd8vWcBbV2w pTNWf2vIExA33xIiA/kDYwDBxwwyEkj623bGM9DcCR2QQVCmAkWw+lPxPLERHu8+wlp5 Ygp14inEj0vWwaafxP1w/+X3rgPkJPFEPzeD5cYZthgxyvDglJF4yOhTcq3RAPr5+0Jp 6/bIsJ+QrFwHgpTRIeZjPMBsq2AbRp6bg/ujfBKKmXBKHhbJI1DA0Qp9WPNV6pU/KZua 3Q5A== 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=1dq1RT36D3fTSQAIxB8ne8rG88frmIHiouUZQUwFQUk=; b=vN7ifR+0Bke8rNcgUt0kZiw62sm73j2YqBe55k2s6JdzuvlrEQ6nGrxn3A9+5JGFkA YqcrSCVVmNsaXZ8bXsuqoxqGMM/KYJLKrXe/HsJz1NmN92BUkgIoaH5QZ9jOTtxNjBvx d8hTp8OnQM18NAwQF3mgSRKq45xw0+pvKB2BNy1i1Uig0KrrjVl9NHBw7bOJtX3RDeow M+3eZwJ/h19SrAtujgFnmBkbCjQ0PGoCzgH4JqQ9jSOYQvGvsAAX9YBQuHid1aXN/6PD QYUhmLemYif9uhLTubiUFKAPb6jE03ALlXtRInDB6HRSXT/CUNIMAQaMC6xU2jeHzQpx cM6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oz4Tr9zG; 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 n11si11206780ejg.99.2021.03.15.07.08.35; Mon, 15 Mar 2021 07:08:59 -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=oz4Tr9zG; 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 S232100AbhCOOGp (ORCPT + 99 others); Mon, 15 Mar 2021 10:06:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:35168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbhCON5p (ORCPT ); Mon, 15 Mar 2021 09:57:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 27DC664DAD; Mon, 15 Mar 2021 13:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816654; bh=rzT91xFi5CSgXz3amxkHUuCpim2XmCzSMYdvJbcna9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oz4Tr9zGLazBR/5oNmUUyYs2kcKxDEaLU5vkIM7n1Tk9ZOVl9HAvH8q90BXBmgazU ObbXih7N3vbB/oyfqO+RQ2VoZletW+yvO2ckUuFOBC4VdEocpp7ueXprn+qUCILVQR 8n9vhyb4JQBybc3R9MGsDwIXwqr1Flg2dxML1qyw= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, DENG Qingfang , Florian Fainelli , Linus Walleij , "David S. Miller" Subject: [PATCH 5.11 044/306] net: dsa: tag_rtl4_a: fix egress tags Date: Mon, 15 Mar 2021 14:51:47 +0100 Message-Id: <20210315135509.134352719@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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: Greg Kroah-Hartman From: DENG Qingfang commit 9eb8bc593a5eed167dac2029abef343854c5ba75 upstream. Commit 86dd9868b878 has several issues, but was accepted too soon before anyone could take a look. - Double free. dsa_slave_xmit() will free the skb if the xmit function returns NULL, but the skb is already freed by eth_skb_pad(). Use __skb_put_padto() to avoid that. - Unnecessary allocation. It has been done by DSA core since commit a3b0b6479700. - A u16 pointer points to skb data. It should be __be16 for network byte order. - Typo in comments. "numer" -> "number". Fixes: 86dd9868b878 ("net: dsa: tag_rtl4_a: Support also egress tags") Signed-off-by: DENG Qingfang Reviewed-by: Florian Fainelli Reviewed-by: Linus Walleij Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/dsa/tag_rtl4_a.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) --- a/net/dsa/tag_rtl4_a.c +++ b/net/dsa/tag_rtl4_a.c @@ -35,14 +35,12 @@ static struct sk_buff *rtl4a_tag_xmit(st struct net_device *dev) { struct dsa_port *dp = dsa_slave_to_port(dev); + __be16 *p; u8 *tag; - u16 *p; u16 out; /* Pad out to at least 60 bytes */ - if (unlikely(eth_skb_pad(skb))) - return NULL; - if (skb_cow_head(skb, RTL4_A_HDR_LEN) < 0) + if (unlikely(__skb_put_padto(skb, ETH_ZLEN, false))) return NULL; netdev_dbg(dev, "add realtek tag to package to port %d\n", @@ -53,13 +51,13 @@ static struct sk_buff *rtl4a_tag_xmit(st tag = skb->data + 2 * ETH_ALEN; /* Set Ethertype */ - p = (u16 *)tag; + p = (__be16 *)tag; *p = htons(RTL4_A_ETHERTYPE); out = (RTL4_A_PROTOCOL_RTL8366RB << 12) | (2 << 8); - /* The lower bits is the port numer */ + /* The lower bits is the port number */ out |= (u8)dp->index; - p = (u16 *)(tag + 2); + p = (__be16 *)(tag + 2); *p = htons(out); return skb;