Skip to contentSkip to conversation

can: usb: delete a redundant dev_kfree_skb() in ems_usb_start_xmit()

PATCH In review Hangyu Hua 2 participants 6 messages Feb 28, 2022 – Mar 11, 2022

Subsystems (3)
lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH 1/1 can: usb: delete a redundant dev_kfree_skb() in ems_usb_start_xmit()

There is no need to call dev_kfree_skb when usb_submit_urb fails beacause can_put_echo_skb deletes original skb and can_free_echo_skb deletes the cloned skb.

---
 drivers/net/can/usb/ems_usb.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/can/usb/ems_usb.c +0 -1
index 7bedceffdfa3..bbec3311d893 100644
@@ -819,7 +819,6 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
 
 		usb_unanchor_urb(urb);
 		usb_free_coherent(dev->udev, size, buf, urb->transfer_dma);
-		dev_kfree_skb(skb);
 
 		atomic_dec(&dev->active_tx_urbs);
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Hangyu Hua

There is no need to call dev_kfree_skb when usb_submit_urb fails beacause can_put_echo_skb deletes original skb and can_free_echo_skb deletes the cloned skb.

Thanks for the patch. Please add a Fixes tag, that points to the commit that introduced the problem, here it's:

Fixes 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface")

I've adjusted the subject a bit ("can: usb: ems_usb_start_xmit(): fix double dev_kfree_skb() in error path") and added stable on Cc.

Added patch to can/testing.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
author
#2 lore raw

I get it. I'll remake a patch that matches your suggestions.

Thanks.

Quoted 20 lines · Marc Kleine-Budde
Quoted 5 lines · Hangyu Hua

There is no need to call dev_kfree_skb when usb_submit_urb fails beacause can_put_echo_skb deletes original skb and can_free_echo_skb deletes the cloned skb.

Thanks for the patch. Please add a Fixes tag, that points to the commit that introduced the problem, here it's:

Fixes 702171adeed3 ("ems_usb: Added support for EMS CPC-USB/ARM7 CAN/USB interface")

I've adjusted the subject a bit ("can: usb: ems_usb_start_xmit(): fix double dev_kfree_skb() in error path") and added stable on Cc.

Added patch to can/testing.

regards,
Marc

#3 lore raw
Quoted 1 line · Hangyu Hua

I get it. I'll remake a patch that matches your suggestions.

Not needed, it's already applied:

Quoted 1 line
Quoted 1 line

Added patch to can/testing.

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
author
#4 lore raw

All right. :)

Quoted 8 lines · Marc Kleine-Budde
Quoted 1 line · Hangyu Hua

I get it. I'll remake a patch that matches your suggestions.

Not needed, it's already applied:

Quoted 1 line
Quoted 1 line

Added patch to can/testing.

Marc

author
#5 lore raw

Hi Marc,

I didn't find this("can: usb: ems_usb_start_xmit(): fix double dev_kfree_skb() in error path") in can/testing. Did I miss it or did you forget to submit it?

Anyway, i find this problem also exists in two other places. You can check them in:
mcba_usb:
https://lore.kernel.org/all/[email protected]/
usb_8dev:
https://lore.kernel.org/all/[email protected]/

Thanks,
Hangyu

Quoted 11 lines · Hangyu Hua

All right. :)

Quoted 8 lines · Marc Kleine-Budde
Quoted 1 line · Hangyu Hua

I get it. I'll remake a patch that matches your suggestions.

Not needed, it's already applied:

Quoted 1 line
Quoted 1 line

Added patch to can/testing.

Marc