Skip to content

Commit 13a9d08

Browse files
Dan Carpenterkuba-moo
authored andcommitted
net: lan966x: improve error handle in lan966x_fdma_rx_get_frame()
Don't just print a warning. Clean up and return an error as well. Fixes: c834963 ("net: lan966x: Add FDMA functionality") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Horatiu Vultur <[email protected]> Link: https://lore.kernel.org/r/YwjgDm/SVd5c1tQU@kili Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 642b212 commit 13a9d08

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
425425
lan966x_ifh_get_src_port(skb->data, &src_port);
426426
lan966x_ifh_get_timestamp(skb->data, &timestamp);
427427

428-
WARN_ON(src_port >= lan966x->num_phys_ports);
428+
if (WARN_ON(src_port >= lan966x->num_phys_ports))
429+
goto free_skb;
429430

430431
skb->dev = lan966x->ports[src_port]->dev;
431432
skb_pull(skb, IFH_LEN * sizeof(u32));
@@ -449,6 +450,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
449450

450451
return skb;
451452

453+
free_skb:
454+
kfree_skb(skb);
452455
unmap_page:
453456
dma_unmap_page(lan966x->dev, (dma_addr_t)db->dataptr,
454457
FDMA_DCB_STATUS_BLOCKL(db->status),

0 commit comments

Comments
 (0)