diff mbox series

[net] net: lan966x: improve error handle in lan966x_fdma_rx_get_frame()

Message ID YwjgDm/SVd5c1tQU@kili (mailing list archive)
State Accepted
Commit 13a9d08c296228d18289de60b83792c586e1d073
Delegated to: Netdev Maintainers
Headers show
Series [net] net: lan966x: improve error handle in lan966x_fdma_rx_get_frame() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 17 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dan Carpenter Aug. 26, 2022, 3 p.m. UTC
Don't just print a warning.  Clean up and return an error as well.

Fixes: c8349639324a ("net: lan966x: Add FDMA functionality")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Horatiu Vultur Aug. 28, 2022, 6:47 p.m. UTC | #1
The 08/26/2022 18:00, Dan Carpenter wrote:
> 
> Don't just print a warning.  Clean up and return an error as well.

Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>

> 
> Fixes: c8349639324a ("net: lan966x: Add FDMA functionality")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> index 6dea7f8c1481..51f8a0816377 100644
> --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
> @@ -425,7 +425,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
>         lan966x_ifh_get_src_port(skb->data, &src_port);
>         lan966x_ifh_get_timestamp(skb->data, &timestamp);
> 
> -       WARN_ON(src_port >= lan966x->num_phys_ports);
> +       if (WARN_ON(src_port >= lan966x->num_phys_ports))
> +               goto free_skb;
> 
>         skb->dev = lan966x->ports[src_port]->dev;
>         skb_pull(skb, IFH_LEN * sizeof(u32));
> @@ -449,6 +450,8 @@ static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
> 
>         return skb;
> 
> +free_skb:
> +       kfree_skb(skb);
>  unmap_page:
>         dma_unmap_page(lan966x->dev, (dma_addr_t)db->dataptr,
>                        FDMA_DCB_STATUS_BLOCKL(db->status),
> --
> 2.35.1
>
patchwork-bot+netdevbpf@kernel.org Aug. 31, 2022, 6:30 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 26 Aug 2022 18:00:30 +0300 you wrote:
> Don't just print a warning.  Clean up and return an error as well.
> 
> Fixes: c8349639324a ("net: lan966x: Add FDMA functionality")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [net] net: lan966x: improve error handle in lan966x_fdma_rx_get_frame()
    https://git.kernel.org/netdev/net/c/13a9d08c2962

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
index 6dea7f8c1481..51f8a0816377 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c
@@ -425,7 +425,8 @@  static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
 	lan966x_ifh_get_src_port(skb->data, &src_port);
 	lan966x_ifh_get_timestamp(skb->data, &timestamp);
 
-	WARN_ON(src_port >= lan966x->num_phys_ports);
+	if (WARN_ON(src_port >= lan966x->num_phys_ports))
+		goto free_skb;
 
 	skb->dev = lan966x->ports[src_port]->dev;
 	skb_pull(skb, IFH_LEN * sizeof(u32));
@@ -449,6 +450,8 @@  static struct sk_buff *lan966x_fdma_rx_get_frame(struct lan966x_rx *rx)
 
 	return skb;
 
+free_skb:
+	kfree_skb(skb);
 unmap_page:
 	dma_unmap_page(lan966x->dev, (dma_addr_t)db->dataptr,
 		       FDMA_DCB_STATUS_BLOCKL(db->status),