diff mbox series

can: flexcan: free error skb if enqueueing failed

Message ID 20190715185308.104333-1-martin@geanix.com
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series can: flexcan: free error skb if enqueueing failed | expand

Commit Message

Martin Hundebøll July 15, 2019, 6:53 p.m. UTC
If the call to can_rx_offload_queue_sorted() fails, the passed skb isn't
consumed, so the caller must do so.

Fixes: 30164759db1b ("can: flexcan: make use of rx-offload's irq_offload_fifo")
Signed-off-by: Martin Hundebøll <martin@geanix.com>
---
 drivers/net/can/flexcan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Martin Hundebøll Aug. 1, 2019, 7:59 a.m. UTC | #1
On 15/07/2019 20.53, Martin Hundebøll wrote:
> If the call to can_rx_offload_queue_sorted() fails, the passed skb isn't
> consumed, so the caller must do so.
> 
> Fixes: 30164759db1b ("can: flexcan: make use of rx-offload's irq_offload_fifo")
> Signed-off-by: Martin Hundebøll <martin@geanix.com>

Ping.
Sean Nyekjaer Aug. 20, 2019, 9:49 a.m. UTC | #2
CC'ing Joakim Zhang

On 15/07/2019 20.53, Martin Hundebøll wrote:
> If the call to can_rx_offload_queue_sorted() fails, the passed skb isn't
> consumed, so the caller must do so.
> 
> Fixes: 30164759db1b ("can: flexcan: make use of rx-offload's irq_offload_fifo")
> Signed-off-by: Martin Hundebøll <martin@geanix.com>
> ---
>   drivers/net/can/flexcan.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index 1c66fb2ad76b..21f39e805d42 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -688,7 +688,8 @@ static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
>   	if (tx_errors)
>   		dev->stats.tx_errors++;
>   
> -	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
> +	if (can_rx_offload_queue_sorted(&priv->offload, skb, timestamp))
> +		kfree_skb(skb);
>   }
>   
>   static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
> @@ -732,7 +733,8 @@ static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
>   	if (unlikely(new_state == CAN_STATE_BUS_OFF))
>   		can_bus_off(dev);
>   
> -	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
> +	if (can_rx_offload_queue_sorted(&priv->offload, skb, timestamp))
> +		kfree_skb(skb);
>   }
>   
>   static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload)
>
Joakim Zhang Aug. 20, 2019, 10:12 a.m. UTC | #3
> -----Original Message-----
> From: Sean Nyekjaer <sean@geanix.com>
> Sent: 2019年8月20日 17:50
> To: Martin Hundebøll <martin@geanix.com>; Wolfgang Grandegger
> <wg@grandegger.com>; Marc Kleine-Budde <mkl@pengutronix.de>;
> linux-can@vger.kernel.org
> Cc: David S . Miller <davem@davemloft.net>; netdev@vger.kernel.org; Joakim
> Zhang <qiangqing.zhang@nxp.com>
> Subject: Re: [PATCH] can: flexcan: free error skb if enqueueing failed
> 
> CC'ing Joakim Zhang

Looks good, so add my tag:
Acked-by: Joakim Zhang <qiangqing.zhang@nxp.com>

Best Regards,
Joakim Zhang
> On 15/07/2019 20.53, Martin Hundebøll wrote:
> > If the call to can_rx_offload_queue_sorted() fails, the passed skb
> > isn't consumed, so the caller must do so.
> >
> > Fixes: 30164759db1b ("can: flexcan: make use of rx-offload's
> > irq_offload_fifo")
> > Signed-off-by: Martin Hundebøll <martin@geanix.com>
> > ---
> >   drivers/net/can/flexcan.c | 6 ++++--
> >   1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> > index 1c66fb2ad76b..21f39e805d42 100644
> > --- a/drivers/net/can/flexcan.c
> > +++ b/drivers/net/can/flexcan.c
> > @@ -688,7 +688,8 @@ static void flexcan_irq_bus_err(struct net_device
> *dev, u32 reg_esr)
> >   	if (tx_errors)
> >   		dev->stats.tx_errors++;
> >
> > -	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
> > +	if (can_rx_offload_queue_sorted(&priv->offload, skb, timestamp))
> > +		kfree_skb(skb);
> >   }
> >
> >   static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
> > @@ -732,7 +733,8 @@ static void flexcan_irq_state(struct net_device *dev,
> u32 reg_esr)
> >   	if (unlikely(new_state == CAN_STATE_BUS_OFF))
> >   		can_bus_off(dev);
> >
> > -	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
> > +	if (can_rx_offload_queue_sorted(&priv->offload, skb, timestamp))
> > +		kfree_skb(skb);
> >   }
> >
> >   static inline struct flexcan_priv *rx_offload_to_priv(struct
> > can_rx_offload *offload)
> >
Sean Nyekjaer Sept. 13, 2019, 9:44 a.m. UTC | #4
On 01/08/2019 09.59, Martin Hundebøll wrote:
> On 15/07/2019 20.53, Martin Hundebøll wrote:
>> If the call to can_rx_offload_queue_sorted() fails, the passed skb isn't
>> consumed, so the caller must do so.
>>
>> Fixes: 30164759db1b ("can: flexcan: make use of rx-offload's 
>> irq_offload_fifo")
>> Signed-off-by: Martin Hundebøll <martin@geanix.com>
> 
> Ping.

Hi Marc

Any problems with this? Besides time ;-)

We really need this to be back ported to 4.19, soon...

/Sean
Marc Kleine-Budde Oct. 10, 2019, 8:08 a.m. UTC | #5
On 7/15/19 8:53 PM, Martin Hundebøll wrote:
> If the call to can_rx_offload_queue_sorted() fails, the passed skb isn't
> consumed, so the caller must do so.
> 
> Fixes: 30164759db1b ("can: flexcan: make use of rx-offload's irq_offload_fifo")
> Signed-off-by: Martin Hundebøll <martin@geanix.com>

I've fixed the problem by adding the kfree_skb() to
can_rx_offload_queue_sorted().

Marc
diff mbox series

Patch

diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1c66fb2ad76b..21f39e805d42 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -688,7 +688,8 @@  static void flexcan_irq_bus_err(struct net_device *dev, u32 reg_esr)
 	if (tx_errors)
 		dev->stats.tx_errors++;
 
-	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	if (can_rx_offload_queue_sorted(&priv->offload, skb, timestamp))
+		kfree_skb(skb);
 }
 
 static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
@@ -732,7 +733,8 @@  static void flexcan_irq_state(struct net_device *dev, u32 reg_esr)
 	if (unlikely(new_state == CAN_STATE_BUS_OFF))
 		can_bus_off(dev);
 
-	can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
+	if (can_rx_offload_queue_sorted(&priv->offload, skb, timestamp))
+		kfree_skb(skb);
 }
 
 static inline struct flexcan_priv *rx_offload_to_priv(struct can_rx_offload *offload)