Skip to contentSkip to conversation

staging: r8188eu: core: Remove rtw_mfree_all_stainfo()

PATCH In review Fabio M. De Francesco 3 participants 6 messages Aug 2, 2021 – Aug 5, 2021 1 message not in the archive Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: core: Remove rtw_mfree_all_stainfo()

Remove rtw_mfree_all_stainfo() and the only line of code that calls it. This function simply takes a spinlock and iterates over a list with no purpose. That iteration has no side effects.

---
 drivers/staging/r8188eu/core/rtw_sta_mgt.c | 22 ----------------------
 1 file changed, 22 deletions(-)
drivers/staging/r8188eu/core/rtw_sta_mgt.c +0 -22
index feaf39fddf7c..dae845ace2ef 100644
@@ -161,34 +161,12 @@ void rtw_mfree_stainfo(struct sta_info *psta)
 
 }
 
-/*  this function is used to free the memory of lock || sema for all stainfos */
-void rtw_mfree_all_stainfo(struct sta_priv *pstapriv);
-void rtw_mfree_all_stainfo(struct sta_priv *pstapriv)
-{
-	struct list_head *plist, *phead;
-	struct sta_info *psta = NULL;
-
-	spin_lock_bh(&pstapriv->sta_hash_lock);
-
-	phead = get_list_head(&pstapriv->free_sta_queue);
-	plist = phead->next;
-
-	while (phead != plist) {
-		psta = container_of(plist, struct sta_info, list);
-		plist = plist->next;
-	}
-
-	spin_unlock_bh(&pstapriv->sta_hash_lock);
-}
-
 static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv)
 {
 #ifdef CONFIG_88EU_AP_MODE
 	struct wlan_acl_pool *pacl_list = &pstapriv->acl_list;
 #endif
 
-	 rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */
-
 	_rtw_spinlock_free(&pstapriv->free_sta_queue.lock);
 
 	_rtw_spinlock_free(&pstapriv->sta_hash_lock);
Signature · 1 line
2.32.0
#1 lore raw
Quoted 4 lines · Fabio M. De Francesco

Remove rtw_mfree_all_stainfo() and the only line of code that calls it. This function simply takes a spinlock and iterates over a list with no purpose. That iteration has no side effects.

I mean, it's pretty clearly supposed to free all the items on the list.

regards,
dan carpenter

#2 lore raw
Quoted 7 lines · CEST Dan Carpenter
Quoted 3 lines · Fabio M. De Francesco

Remove rtw_mfree_all_stainfo() and the only line of code that calls it. This function simply takes a spinlock and iterates over a list with no purpose. That iteration has no side effects.

I mean, it's pretty clearly supposed to free all the items on the list.

Sorry, I'm not sure to understand what you required:
since rtw_mfree_all_stainfo() is supposed to free all the nodes on the list, should a better patch *really* delete those items (instead than simply get rid of the function itself)?

Thanks,

Fabio

Quoted 3 lines

regards,
dan carpenter

A message that is not in the archive (sent off-list or not yet received): CAP71bdUDEX=B6Km9wZO1AyHpVzqqkGNw6xNvspBz3qUABSKMEQ@mail.gmail.com

Acked-by
#4 lore raw
Quoted 1 line · Larry Finger

In other Realtek drivers, the while loop has a call to rtw_mfree_stainfo(psta). That routine does not exist in this driver, but I think it should. In a few rare instances, the driver leaks some memory - this missing code may explain that. In any case, this patch should be dropped as the fix will require testing.

After looking at the original code for several other drivers, routine rtw_mfree_stainfo() just ends up calling a couple of routines that free a spinlock. That operation for Windows and FreeBSD is not trivial, but for Linux, the routine does nothing. Thus, despite its name, rtw_mfree_stainfo() does not free anything, and it can be deleted.

The original patch is

Larry

Acked-by
#5 lore raw
Quoted 13 lines · Larry Finger
Quoted 5 lines · Larry Finger

In other Realtek drivers, the while loop has a call to rtw_mfree_stainfo(psta). That routine does not exist in this driver, but I think it should. In a few rare instances, the driver leaks some memory
- this missing code may explain that. In any case, this patch should be dropped as the fix will require testing.

After looking at the original code for several other drivers, routine rtw_mfree_stainfo() just ends up calling a couple of routines that free a spinlock. That operation for Windows and FreeBSD is not trivial, but for Linux, the routine does nothing. Thus, despite its name, rtw_mfree_stainfo() does not free anything, and it can be deleted.

Quoted 3 lines

The original patch is

Thanks, Larry!

regards,
dan carpenter

#6 lore raw
In reply to Larry Finger
Quoted 7 lines · CEST Larry Finger

On 8/4/21 10:09 AM, Larry Finger wrote:

[]

After looking at the original code for several other drivers, routine rtw_mfree_stainfo() just ends up calling a couple of routines that free a spinlock. That operation for Windows and FreeBSD is not trivial, but for

Linux,

Quoted 1 line

the routine does nothing. Thus, despite its name, rtw_mfree_stainfo() does

not

Quoted 7 lines

free anything, and it can be deleted.

The original patch is

Larry

Larry,

Thanks for looking at that routine and acking my patch,

Fabio