public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Horatiu Vultur <horatiu.vultur@microchip.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <UNGLinuxDriver@microchip.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>, <netdev@vger.kernel.org>,
	<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH net] net: lan966x: improve error handle in lan966x_fdma_rx_get_frame()
Date: Sun, 28 Aug 2022 20:47:48 +0200	[thread overview]
Message-ID: <20220828184748.e446pjykjklesxja@soft-dev3-1.localhost> (raw)
In-Reply-To: <YwjgDm/SVd5c1tQU@kili>

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
> 

-- 
/Horatiu

  reply	other threads:[~2022-08-28 18:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-26 15:00 [PATCH net] net: lan966x: improve error handle in lan966x_fdma_rx_get_frame() Dan Carpenter
2022-08-28 18:47 ` Horatiu Vultur [this message]
2022-08-31  6:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220828184748.e446pjykjklesxja@soft-dev3-1.localhost \
    --to=horatiu.vultur@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox