From: Christian Marangi Date: Sun, 30 Jul 2023 07:41:09 +0000 (+0200) Subject: net: dsa: tag_qca: return early if dev is not found X-Git-Tag: v6.6.17~4098^2~275 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de9db136dcc3b60ba99f1f5034fc6ae7af45fa99;p=platform%2Fkernel%2Flinux-rpi.git net: dsa: tag_qca: return early if dev is not found Currently checksum is recalculated and dsa tag stripped even if we later don't find the dev. To improve code, exit early if we don't find the dev and skip additional operation on the skb since it will be freed anyway. Signed-off-by: Christian Marangi Reviewed-by: Simon Horman Reviewed-by: Vladimir Oltean Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20230730074113.21889-1-ansuelsmth@gmail.com Signed-off-by: Paolo Abeni --- diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index e757c8d..e5ff7c3 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c @@ -75,10 +75,6 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) return NULL; } - /* Remove QCA tag and recalculate checksum */ - skb_pull_rcsum(skb, QCA_HDR_LEN); - dsa_strip_etype_header(skb, QCA_HDR_LEN); - /* Get source port information */ port = FIELD_GET(QCA_HDR_RECV_SOURCE_PORT, hdr); @@ -86,6 +82,10 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev) if (!skb->dev) return NULL; + /* Remove QCA tag and recalculate checksum */ + skb_pull_rcsum(skb, QCA_HDR_LEN); + dsa_strip_etype_header(skb, QCA_HDR_LEN); + return skb; }