Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3322085pxf; Mon, 15 Mar 2021 07:07:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlqeImFdSb09SLJ+ZBX3HBPmhUoCRsSz6MjY9CBxI/MK44nf1L6ptIX8ZL9s20FEoqN9vB X-Received: by 2002:a17:906:5689:: with SMTP id am9mr22973166ejc.298.1615817230015; Mon, 15 Mar 2021 07:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615817230; cv=none; d=google.com; s=arc-20160816; b=dxs00oYh0U1qBeT1e8dCaIt+eaO+TpUecEJf04g/l/IXbZm2jJE/Oy6/wLc+LKdf7o BNVlKjrO7lmSTn8Gnc9dyp/6LDsBG9zS7CJu7QWYOSBlVo6camblGe5aWJc7/g16bQq9 fng+dce8zaonf0BZXoKoLbZw7jv338EdzswgP1DLpwPY2ehUFizZYPx2Pvy01954P7ts 6HTuBh6XPxFADfZj74FyaeP5wEyMQF3I5Gc1/peL5HQ33BUGmclsockX9zCoogeuS8+o iGvJ0ofDUx/JrPo9OpxpADVJtR/8hwAFWFNIvZlWQlGOlpCg0Oww4edFp97T5O/JHl+j P0nw== 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=wJs5iQOpPRKN5iDRhAj33bmKjkwyKI+OC5nIu4pmFHgfLcwCvhKICCAPLKWeMchY1Y 9s6VWYD96ckItbpXLs95ApN5Dp5/0QouGeYaG08gtkQ478myAq9YsOmhmHCGTgw51l3s 3JlceMczFU9Rv6iQWmJvP/pSnVoWzkMfbZ3BV66aKLnU44I25OnBRbzkS1P1DwzwRsqU lWGIcS7+BpkSlP7AMetJoaSOZhSyEdf908V8sg+CQ//qHHP1Iz9pP10iRXHBrKzAvJzf 86yxNmXqf8jPx9T1AfejX9z6CEXzt1jEE6Ls2tmABzBEUlOG6A9rXChYg+DpllxaedPm 5oaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fq17ApAW; 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 c26si11316142edn.447.2021.03.15.07.06.47; Mon, 15 Mar 2021 07:07:10 -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=fq17ApAW; 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 S234745AbhCOOFl (ORCPT + 99 others); Mon, 15 Mar 2021 10:05:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:35126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231904AbhCON5d (ORCPT ); Mon, 15 Mar 2021 09:57:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CB72D64F05; Mon, 15 Mar 2021 13:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816653; bh=rzT91xFi5CSgXz3amxkHUuCpim2XmCzSMYdvJbcna9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fq17ApAWspDrXVqXoxDOfD27u+aJze5sHXnLi9GhNMypO0HNjE61x9udCjPP+FZyR 7IbHvr2ty25gyYLq+smSIwnOUEQ65K9ZR4uk8qqCyf5Jbtc130hdb/O/5hsAV9WjOa d4mO2c6XKl30DK3v6x4GTkBgzSZa3kNS0rwNfD6U= 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.10 035/290] net: dsa: tag_rtl4_a: fix egress tags Date: Mon, 15 Mar 2021 14:52:08 +0100 Message-Id: <20210315135543.109508081@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@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;