2020-07-18 05:27:15

by Navid Emamdoost

[permalink] [raw]
Subject: [PATCH] mt7601u: add missing release on skb in mt7601u_mcu_msg_send

In the implementation of mt7601u_mcu_msg_send(), skb is supposed to be
consumed on all execution paths. Release skb before returning if
test_bit() fails.

Signed-off-by: Navid Emamdoost <[email protected]>
---
drivers/net/wireless/mediatek/mt7601u/mcu.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt7601u/mcu.c b/drivers/net/wireless/mediatek/mt7601u/mcu.c
index af55ed82b96f..1b5cc271a9e1 100644
--- a/drivers/net/wireless/mediatek/mt7601u/mcu.c
+++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c
@@ -116,8 +116,10 @@ mt7601u_mcu_msg_send(struct mt7601u_dev *dev, struct sk_buff *skb,
int sent, ret;
u8 seq = 0;

- if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
+ if (test_bit(MT7601U_STATE_REMOVED, &dev->state)) {
+ consume_skb(skb);
return 0;
+ }

mutex_lock(&dev->mcu.mutex);

--
2.17.1


2020-07-18 14:49:56

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH] mt7601u: add missing release on skb in mt7601u_mcu_msg_send


> +++ b/drivers/net/wireless/mediatek/mt7601u/mcu.c
> @@ -116,8 +116,10 @@ mt7601u_mcu_msg_send(struct mt7601u_dev *dev, struct sk_buff *skb,
> int sent, ret;
> u8 seq = 0;
>
> - if (test_bit(MT7601U_STATE_REMOVED, &dev->state))
> + if (test_bit(MT7601U_STATE_REMOVED, &dev->state)) {
> + consume_skb(skb);
> return 0;
> + }


How do you think about to use the the following statements instead
in the if branch?

ret = 0;
goto consume_skb;


Would you like to add the tag “Fixes” to the commit message?

Regards,
Markus

2020-07-20 16:39:23

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] mt7601u: add missing release on skb in mt7601u_mcu_msg_send

On Sat, 18 Jul 2020 00:26:29 -0500 Navid Emamdoost wrote:
> In the implementation of mt7601u_mcu_msg_send(), skb is supposed to be
> consumed on all execution paths. Release skb before returning if
> test_bit() fails.
>
> Signed-off-by: Navid Emamdoost <[email protected]>

Acked-by: Jakub Kicinski <[email protected]>