Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4364163pxb; Tue, 2 Mar 2021 13:14:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUIN+ebm+dekcVscDd3Afm2Sjf7WgwQpBjBscMYSG+IgZ2Nx2xVxwRbl3ET04vzrhrL+D7 X-Received: by 2002:a17:906:7102:: with SMTP id x2mr4827477ejj.355.1614719645858; Tue, 02 Mar 2021 13:14:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614719645; cv=none; d=google.com; s=arc-20160816; b=gMI0tS48imQ+3x6bOYd3Gf3xdHCbdb7dkeX9hNvDYGcx1elf4tSWkUtJOH/SFCcdj4 kVZnDJeapBQehkWE19BYgnpG9mbX1JlSInH3pGb55vvyEuNfciuvBESO4OeVRPDr5NRl haB94F+v2FOPwGJS+3r4QEWjWKft0ZhPQ4Qb0uGDu9m9SnLQfHotn3LaWKkq2y7ubP0q KCKCSP7MjcCqfbQRJUh2VsMljSsBwxILoiVzYJIDOS+dD7wfZvBWBZxHNrEeJ7nlx1zR BaXyYGoubbVZ9R99gu4y/A1QNNt6NZzavjqJ2PR2ilR8CQIpOuDXXU5gE/jELgtvLwvy zEgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=agB1pi024Vr3XPHFnK8A8uxx+WSFW4Ss4wEt+UUGomA=; b=v1pwp/S6/3wVGOZ1MudKGXDXL2BOThd+W1N58T1XFdLumnY9ND2pEjfsv7SWL2f5Dz Lfos4kbb0R/ahftYGiQpe8JvEULoll/gd1/REabYkTcDw9eUR5/AU6cHWVX+qTUt/QcA g5dacrwXKIrcRdvPoiRH31h3Us7lmSoH6V82gtFj7h/90epV1MRRuW08dZwaGS0RZGQi TNNxezDqePNtvwjanTy8u4UBqotsQ5nQCelYYo4hBT6oLUZYZRSUaJqQeF64V+7f8IQy AybVfd57kxqPReKDVoUZn+6AUsoHS+LQHvdj3YUtpDEMe54oVgZvE2eTtdH0WixkDhcK 1sAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=J2KxhfvY; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bh4si357217ejb.554.2021.03.02.13.13.42; Tue, 02 Mar 2021 13:14:05 -0800 (PST) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=J2KxhfvY; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382228AbhCBJHq (ORCPT + 99 others); Tue, 2 Mar 2021 04:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241250AbhCBIve (ORCPT ); Tue, 2 Mar 2021 03:51:34 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F1ADC0617AA for ; Tue, 2 Mar 2021 00:42:38 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id dx17so6093790ejb.2 for ; Tue, 02 Mar 2021 00:42:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=agB1pi024Vr3XPHFnK8A8uxx+WSFW4Ss4wEt+UUGomA=; b=J2KxhfvYp/C4dNeiEuJ9uuzNtGkOnSWtZXhIKfyFPrvIRJ6Uz0nzrFUHlf/AJVfTX/ pLADSL75J4ZVY+zeYfSOGPpkv9fP0XuJELCjv+CBzNjYyvbNqlvNEdO8o54dfEDtVYBf B8f+aY0ITlqdbI9sz70TTv+y26cx4W3D683xiB7w6RgFMzqfamj5eb16BuAy55JtBSXb dHUXhCpLl5GWmGLxuqBy+sAutKvDqQuvAKeG1lj97jpL5H7RzgzsMY62RMWRXHXy0Zc9 6g2R/ewhXtTLFZtKya22iW6Hyt61B1lPKlWAWzZPyyeUvdmeh2YHExJZm3eape88OnIr 0+Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=agB1pi024Vr3XPHFnK8A8uxx+WSFW4Ss4wEt+UUGomA=; b=dSGsRysr7CaKGfGXK0Z3q2KaNUdYIMJZedtgbbo3jO2i6tO0RFEX6HUcfHV9KHfM38 RfPP0hmcMQ9p1D5E/grPu3Aum50b1dq+5rhgKJ1TUG+RNrAinFPjpcWg9ElKzO5keBsi n3GcvdCRuW+02g9KPwyfVz/hy65r0+qcoq8EaM+vU/FkyDovbQcb5kxuL6jSlw3hnDqn Nw1A8T1PEJcfyU8b+LA5ddB8yzsZxz/yoQgnlRbWV8AupPEH9y+oe32tY8ZHQqf/8l90 CtMf/tQylagKMavX0zaaMnyzdynAkaFLdifC/1mlVvifCnIquVZCRe771z1dhMWPWaqZ ekxg== X-Gm-Message-State: AOAM533qKbI1HIXCYPKZKtzAsgMMp9Pmx0OWZYdQxOmi42rJpZm1+daZ K/BVQht4vENk70u7oDo/zOI4i4fYMKNjPNq+/66byw== X-Received: by 2002:a17:906:3105:: with SMTP id 5mr20113035ejx.168.1614674557016; Tue, 02 Mar 2021 00:42:37 -0800 (PST) MIME-Version: 1.0 References: <20210302033323.25830-1-biao.huang@mediatek.com> In-Reply-To: <20210302033323.25830-1-biao.huang@mediatek.com> From: Bartosz Golaszewski Date: Tue, 2 Mar 2021 09:42:26 +0100 Message-ID: Subject: Re: [PATCH] net: ethernet: mtk-star-emac: fix wrong unmap in RX handling To: Biao Huang Cc: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , "David S . Miller" , Jakub Kicinski , Matthias Brugger , netdev , arm-soc , "moderated list:ARM/Mediatek SoC..." , LKML , srv_heupstream Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 2, 2021 at 4:33 AM Biao Huang wrote: > > mtk_star_dma_unmap_rx() should unmap the dma_addr of old skb rather than > that of new skb. > Assign new_dma_addr to desc_data.dma_addr after all handling of old skb > ends to avoid unexpected receive side error. > > Fixes: f96e9641e92b ("net: ethernet: mtk-star-emac: fix error path in RX handling") > Signed-off-by: Biao Huang > --- > drivers/net/ethernet/mediatek/mtk_star_emac.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mediatek/mtk_star_emac.c b/drivers/net/ethernet/mediatek/mtk_star_emac.c > index a8641a407c06..96d2891f1675 100644 > --- a/drivers/net/ethernet/mediatek/mtk_star_emac.c > +++ b/drivers/net/ethernet/mediatek/mtk_star_emac.c > @@ -1225,8 +1225,6 @@ static int mtk_star_receive_packet(struct mtk_star_priv *priv) > goto push_new_skb; > } > > - desc_data.dma_addr = new_dma_addr; > - > /* We can't fail anymore at this point: it's safe to unmap the skb. */ > mtk_star_dma_unmap_rx(priv, &desc_data); > > @@ -1236,6 +1234,9 @@ static int mtk_star_receive_packet(struct mtk_star_priv *priv) > desc_data.skb->dev = ndev; > netif_receive_skb(desc_data.skb); > > + /* update dma_addr for new skb */ > + desc_data.dma_addr = new_dma_addr; > + > push_new_skb: > desc_data.len = skb_tailroom(new_skb); > desc_data.skb = new_skb; > -- > 2.18.0 > Thanks for spotting that. Maybe also update the commit so that it says: "it's safe to unmap the old skb"? Would make the thing clearer IMO. In any case: Acked-by: Bartosz Golaszewski Bartosz