diff mbox series

[net] net: rswitch: Fix error path in rswitch_start_xmit()

Message ID 20231121055255.3627949-1-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net] net: rswitch: Fix error path in rswitch_start_xmit() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/codegen success Generated files up to date
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1115 this patch: 1115
netdev/cc_maintainers fail 1 blamed authors not CCed: alexanderduyck@fb.com; 1 maintainers not CCed: alexanderduyck@fb.com
netdev/build_clang success Errors and warnings before: 1142 this patch: 1142
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
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: 1142 this patch: 1142
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yoshihiro Shimoda Nov. 21, 2023, 5:52 a.m. UTC
This .ndo_start_xmit() function should return netdev_tx_t value,
not -ENOMEM. Also, before returning the function, dev_kfree_skb_any()
should be called. So, fix them.

Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
 drivers/net/ethernet/renesas/rswitch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Sergey Shtylyov Nov. 21, 2023, 8:55 a.m. UTC | #1
On 11/21/23 8:52 AM, Yoshihiro Shimoda wrote:

> This .ndo_start_xmit() function should return netdev_tx_t value,
> not -ENOMEM. Also, before returning the function, dev_kfree_skb_any()
> should be called. So, fix them.

   Sounds like 2 separate issues -- each needing a patch of its own...

> Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> ---
>  drivers/net/ethernet/renesas/rswitch.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> index 43a7795d6591..fc9dcf5fa166 100644
> --- a/drivers/net/ethernet/renesas/rswitch.c
> +++ b/drivers/net/ethernet/renesas/rswitch.c
> @@ -1535,7 +1535,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
>  		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
>  		if (!ts_info) {
>  			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
> -			return -ENOMEM;
> +			dev_kfree_skb_any(skb);
> +			return ret;

   Looks like we have the same error path as when dma_mapping_error()
returns error. Shouldn't we use *goto*? Although probably can be done
later, as a cleanup...

[...]

MBR, Sergey
Yoshihiro Shimoda Nov. 21, 2023, 11:41 p.m. UTC | #2
Hello,

> From: Sergey Shtylyov, Sent: Tuesday, November 21, 2023 5:56 PM
> 
> On 11/21/23 8:52 AM, Yoshihiro Shimoda wrote:
> 
> > This .ndo_start_xmit() function should return netdev_tx_t value,
> > not -ENOMEM. Also, before returning the function, dev_kfree_skb_any()
> > should be called. So, fix them.
> 
>    Sounds like 2 separate issues -- each needing a patch of its own...

Thank you for your review! I got it.

> > Fixes: 33f5d733b589 ("net: renesas: rswitch: Improve TX timestamp accuracy")
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> >  drivers/net/ethernet/renesas/rswitch.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
> > index 43a7795d6591..fc9dcf5fa166 100644
> > --- a/drivers/net/ethernet/renesas/rswitch.c
> > +++ b/drivers/net/ethernet/renesas/rswitch.c
> > @@ -1535,7 +1535,8 @@ static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
> >  		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
> >  		if (!ts_info) {
> >  			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
> > -			return -ENOMEM;
> > +			dev_kfree_skb_any(skb);
> > +			return ret;
> 
>    Looks like we have the same error path as when dma_mapping_error()
> returns error. Shouldn't we use *goto*? Although probably can be done
> later, as a cleanup...

Thank you for your suggestion. Perhaps, using goto is better. I'll make a such a patch on v2.

Best regards,
Yoshihiro Shimoda

> [...]
> 
> MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 43a7795d6591..fc9dcf5fa166 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -1535,7 +1535,8 @@  static netdev_tx_t rswitch_start_xmit(struct sk_buff *skb, struct net_device *nd
 		ts_info = kzalloc(sizeof(*ts_info), GFP_ATOMIC);
 		if (!ts_info) {
 			dma_unmap_single(ndev->dev.parent, dma_addr, skb->len, DMA_TO_DEVICE);
-			return -ENOMEM;
+			dev_kfree_skb_any(skb);
+			return ret;
 		}
 
 		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;