From patchwork Wed Oct 26 09:35:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miquel Raynal X-Patchwork-Id: 13020384 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC6EFC433FE for ; Wed, 26 Oct 2022 09:35:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230134AbiJZJfX (ORCPT ); Wed, 26 Oct 2022 05:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233111AbiJZJfN (ORCPT ); Wed, 26 Oct 2022 05:35:13 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C1E5B7F4A; Wed, 26 Oct 2022 02:35:12 -0700 (PDT) Received: (Authenticated sender: miquel.raynal@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id BE46B20002; Wed, 26 Oct 2022 09:35:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1666776909; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4ZB5f0usf5IvMcUvkbGgXBKLz/Oi1uhjhHZiBstgC44=; b=lVYi0HdhoqiRdiRgwOB8205END4+BwCRrm6LMc8bep3dWPqLj+v0fQpjVvCczq6iZjMDf6 QXuMA5LTKmWnsTHFWsTC2CFRztct0x2QnnfJ/6mJasvuqLbm05WVNDFUVsrY49uLFmUOtv MH49BMhGAo1mxC27S58GVmQ4KpXNKarpJfIQ7qf7cGwAqqxahvT+5fiVgolpTdOhAxhHAS Vo/dkPOPRrL/FXI8yM5S6BKHddl1HKfSh1yVyF7FYYp61/vcReDB7hnbmC3TL7I38JcLob tp/t5NopSpR3eF0UNnLEYhuKBlrP56lr2Y4Cu9fbkCUwKTFXBBL2Mc/n86v5bA== From: Miquel Raynal To: Alexander Aring , Stefan Schmidt , linux-wpan@vger.kernel.org Cc: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , netdev@vger.kernel.org, David Girault , Romuald Despres , Frederic Blain , Nicolas Schodet , Guilhem Imberton , Thomas Petazzoni , Miquel Raynal Subject: [PATCH wpan-next v2 1/3] mac802154: Move an skb free within the rx path Date: Wed, 26 Oct 2022 11:35:00 +0200 Message-Id: <20221026093502.602734-2-miquel.raynal@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221026093502.602734-1-miquel.raynal@bootlin.com> References: <20221026093502.602734-1-miquel.raynal@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It may appear clearer to free the skb at the end of the path rather than in the middle, within a helper. Move kfree_skb() from the end of __ieee802154_rx_handle_packet() to right after it in the calling function ieee802154_rx(). Doing so implies reworking a little bit the exit path. Suggested-by: Alexander Aring Signed-off-by: Miquel Raynal --- net/mac802154/rx.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c index 334aa4e415cc..9f3e72a278cb 100644 --- a/net/mac802154/rx.c +++ b/net/mac802154/rx.c @@ -234,8 +234,6 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local, skb = NULL; break; } - - kfree_skb(skb); } static void @@ -274,7 +272,7 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb) WARN_ON_ONCE(softirq_count() == 0); if (local->suspended) - goto drop; + goto free_skb; /* TODO: When a transceiver omits the checksum here, we * add an own calculated one. This is currently an ugly @@ -292,20 +290,17 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb) /* Level 1 filtering: Check the FCS by software when relevant */ if (local->hw.phy->filtering == IEEE802154_FILTERING_NONE) { crc = crc_ccitt(0, skb->data, skb->len); - if (crc) { - rcu_read_unlock(); + if (crc) goto drop; - } } /* remove crc */ skb_trim(skb, skb->len - 2); __ieee802154_rx_handle_packet(local, skb); - rcu_read_unlock(); - - return; drop: + rcu_read_unlock(); +free_skb: kfree_skb(skb); }