diff mbox series

wifi: mac80211: fix memory leak in ieee80211_if_add()

Message ID 20221117064500.319983-1-shaozhengchao@huawei.com (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series wifi: mac80211: fix memory leak in ieee80211_if_add() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 7 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Nov. 17, 2022, 6:45 a.m. UTC
When register_netdevice() failed in ieee80211_if_add(), ndev->tstats
isn't released. Fix it.

Fixes: 5a490510ba5f ("mac80211: use per-CPU TX/RX statistics")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/mac80211/iface.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Eric Dumazet Jan. 13, 2023, 8:15 a.m. UTC | #1
On 11/17/22 07:45, Zhengchao Shao wrote:
> When register_netdevice() failed in ieee80211_if_add(), ndev->tstats
> isn't released. Fix it.
>
> Fixes: 5a490510ba5f ("mac80211: use per-CPU TX/RX statistics")
> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
> ---
>   net/mac80211/iface.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
> index dd9ac1f7d2ea..46f08ec5ed76 100644
> --- a/net/mac80211/iface.c
> +++ b/net/mac80211/iface.c
> @@ -2258,6 +2258,7 @@ int ieee80211_if_add(struct ieee80211_local *local, const char *name,
>   
>   		ret = cfg80211_register_netdevice(ndev);
>   		if (ret) {
> +			ieee80211_if_free(ndev);
>   			free_netdev(ndev);
>   			return ret;
>   		}


Note: I will send a revert of this buggy patch, this was adding a double 
free.
shaozhengchao Jan. 14, 2023, 2:53 a.m. UTC | #2
On 2023/1/13 16:15, Eric Dumazet wrote:
> 
> On 11/17/22 07:45, Zhengchao Shao wrote:
>> When register_netdevice() failed in ieee80211_if_add(), ndev->tstats
>> isn't released. Fix it.
>>
>> Fixes: 5a490510ba5f ("mac80211: use per-CPU TX/RX statistics")
>> Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
>> ---
>>   net/mac80211/iface.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
>> index dd9ac1f7d2ea..46f08ec5ed76 100644
>> --- a/net/mac80211/iface.c
>> +++ b/net/mac80211/iface.c
>> @@ -2258,6 +2258,7 @@ int ieee80211_if_add(struct ieee80211_local 
>> *local, const char *name,
>>           ret = cfg80211_register_netdevice(ndev);
>>           if (ret) {
>> +            ieee80211_if_free(ndev);
>>               free_netdev(ndev);
>>               return ret;
>>           }
> 
> 
> Note: I will send a revert of this buggy patch, this was adding a double 
> free.
> 
> 
Hi Eric:
	Thank you very much for pointing out my problem. I'll be more
rigorous in the future.

Zhengchao Shao
>
diff mbox series

Patch

diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
index dd9ac1f7d2ea..46f08ec5ed76 100644
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -2258,6 +2258,7 @@  int ieee80211_if_add(struct ieee80211_local *local, const char *name,
 
 		ret = cfg80211_register_netdevice(ndev);
 		if (ret) {
+			ieee80211_if_free(ndev);
 			free_netdev(ndev);
 			return ret;
 		}