Skip to content

Commit 4d1c7d8

Browse files
miquelraynalStefan-Schmidt
authored andcommitted
mac802154: Move an skb free within the rx path
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 <alex.aring@gmail.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Acked-by: Alexander Aring <aahringo@redhat.com> Link: https://lore.kernel.org/r/20221026093502.602734-2-miquel.raynal@bootlin.com Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
1 parent 95d9a3d commit 4d1c7d8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

net/mac802154/rx.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ __ieee802154_rx_handle_packet(struct ieee802154_local *local,
234234
skb = NULL;
235235
break;
236236
}
237-
238-
kfree_skb(skb);
239237
}
240238

241239
static void
@@ -274,7 +272,7 @@ void ieee802154_rx(struct ieee802154_local *local, struct sk_buff *skb)
274272
WARN_ON_ONCE(softirq_count() == 0);
275273

276274
if (local->suspended)
277-
goto drop;
275+
goto free_skb;
278276

279277
/* TODO: When a transceiver omits the checksum here, we
280278
* 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)
292290
/* Level 1 filtering: Check the FCS by software when relevant */
293291
if (local->hw.phy->filtering == IEEE802154_FILTERING_NONE) {
294292
crc = crc_ccitt(0, skb->data, skb->len);
295-
if (crc) {
296-
rcu_read_unlock();
293+
if (crc)
297294
goto drop;
298-
}
299295
}
300296
/* remove crc */
301297
skb_trim(skb, skb->len - 2);
302298

303299
__ieee802154_rx_handle_packet(local, skb);
304300

305-
rcu_read_unlock();
306-
307-
return;
308301
drop:
302+
rcu_read_unlock();
303+
free_skb:
309304
kfree_skb(skb);
310305
}
311306

0 commit comments

Comments
 (0)