Skip to contentSkip to conversation

staging: r8188eu: core: remove null check before vfree

PATCH Superseded Saurav Girepunje 4 participants 6 messages Aug 28, 2021 Staging

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: r8188eu: core: remove null check before vfree

Remove NULL check. NULL check before freeing function is not needed.

---
 drivers/staging/r8188eu/core/rtw_sta_mgt.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_sta_mgt.c +1 -3
index f6dffed53a60..4726771a8403 100644
@@ -155,9 +155,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
 		spin_unlock_bh(&pstapriv->sta_hash_lock);
 		/*===============================*/
 
-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
-		}
+		vfree(pstapriv->pallocated_stainfo_buf);
 
 	return _SUCCESS;
 }

--
2.32.0

Acked-by on v1 1/1
#1 lore raw
Quoted 23 lines · Saurav Girepunje

Remove NULL check. NULL check before freeing function is not needed.

---
  drivers/staging/r8188eu/core/rtw_sta_mgt.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_sta_mgt.c +1 -4
index f6dffed53a60..4726771a8403 100644
@@ -155,9 +155,7 @@ u32	_rtw_free_sta_priv(struct	sta_priv *pstapriv)
  		spin_unlock_bh(&pstapriv->sta_hash_lock);
  		/*===============================*/
 
-		if (pstapriv->pallocated_stainfo_buf)
-			vfree(pstapriv->pallocated_stainfo_buf);
-		}
+		vfree(pstapriv->pallocated_stainfo_buf);
 
  	return _SUCCESS;
  }
--
Quoted 2 lines

2.32.0

Thanks,
Michael

#5 lore raw
In reply to Saurav Girepunje
Thank you for the patch! Yet something to improve:

Hi Saurav,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on staging/staging-testing]

url:    https://github.com/0day-ci/linux/commits/Saurav-Girepunje/staging-r8188eu-core-remove-null-check-before-vfree/20210829-015616
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 4adb389e08c95fdf91995271932c59250ff0d561
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/9c7f84adad9db1009055b063408e70c89fc51170
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Saurav-Girepunje/staging-r8188eu-core-remove-null-check-before-vfree/20210829-015616 git checkout 9c7f84adad9db1009055b063408e70c89fc51170
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sh SHELL=/bin/bash drivers/staging/

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

drivers/staging/r8188eu/core/rtw_sta_mgt.c: In function '_rtw_free_sta_priv':

>> drivers/staging/r8188eu/core/rtw_sta_mgt.c:163:1: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
     163 | struct  sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
         | ^~~~~~
>> drivers/staging/r8188eu/core/rtw_sta_mgt.c:506:1: error: expected declaration or statement at end of input
     506 | }
         | ^

drivers/staging/r8188eu/core/rtw_sta_mgt.c:507: error: control reaches end of non-void function [-Werror=return-type] At top level:
drivers/staging/r8188eu/core/rtw_sta_mgt.c:469:4: warning: 'rtw_access_ctrl' defined but not used [-Wunused-function]
469 | u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr)
| ^~~~~~~~~~~~~~~
drivers/staging/r8188eu/core/rtw_sta_mgt.c:458:18: warning: 'rtw_get_bcmc_stainfo' defined but not used [-Wunused-function]
458 | struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter)
| ^~~~~~~~~~~~~~~~~~~~
drivers/staging/r8188eu/core/rtw_sta_mgt.c:436:5: warning: 'rtw_init_bcmc_stainfo' defined but not used [-Wunused-function]
436 | u32 rtw_init_bcmc_stainfo(struct adapter *padapter)
| ^~~~~~~~~~~~~~~~~~~~~
drivers/staging/r8188eu/core/rtw_sta_mgt.c:367:6: warning: 'rtw_free_all_stainfo' defined but not used [-Wunused-function]
367 | void rtw_free_all_stainfo(struct adapter *padapter)
| ^~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for SND_ATMEL_SOC_PDC
Depends on SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && HAS_DMA Selected by
- SND_ATMEL_SOC_SSC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC
- SND_ATMEL_SOC_SSC_PDC && SOUND && !UML && SND && SND_SOC && SND_ATMEL_SOC && ATMEL_SSC

vim +506 drivers/staging/r8188eu/core/rtw_sta_mgt.c

15865124feed88 Phillip Potter 2021-07-28 504
15865124feed88 Phillip Potter 2021-07-28 505 return res;
15865124feed88 Phillip Potter 2021-07-28 @506 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
In reply to Michael Straube
Quoted 30 lines · Michael Straube
Quoted 22 lines · Saurav Girepunje

Remove NULL check. NULL check before freeing function is not needed.

---
  drivers/staging/r8188eu/core/rtw_sta_mgt.c | 4 +---

  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_sta_mgt.c +1 -3
index f6dffed53a60..4726771a8403 100644
@@ -155,9 +155,7 @@ u32    _rtw_free_sta_priv(struct    sta_priv 
 *pstapriv)
           spin_unlock_bh(&pstapriv->sta_hash_lock);
           /*===============================*/
 
-        if (pstapriv->pallocated_stainfo_buf)
-            vfree(pstapriv->pallocated_stainfo_buf);
-        }
+        vfree(pstapriv->pallocated_stainfo_buf);
 
       return _SUCCESS;
Quoted 4 lines

  }

Signature · 1 line
2.32.0
Quoted 2 lines

Thanks,
Michael

Whoops, I missed that you removed the } that belongs to the enclosing if block. Probably because it is not properly indented in the original code.

Best regards,
Michael

#3 lore raw
Quoted 32 lines · Michael Straube
Quoted 31 lines · Michael Straube
Quoted 23 lines · Saurav Girepunje

Remove NULL check. NULL check before freeing function is not needed.

---
  drivers/staging/r8188eu/core/rtw_sta_mgt.c | 4 +---

  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_sta_mgt.c +1 -3
index f6dffed53a60..4726771a8403 100644
@@ -155,9 +155,7 @@ u32    _rtw_free_sta_priv(struct    sta_priv
 *pstapriv)
           spin_unlock_bh(&pstapriv->sta_hash_lock);
           /*===============================*/
 
-        if (pstapriv->pallocated_stainfo_buf)
-            vfree(pstapriv->pallocated_stainfo_buf);
-        }
+        vfree(pstapriv->pallocated_stainfo_buf);
 
       return _SUCCESS;
Quoted 4 lines

  }

Signature · 1 line
2.32.0
Quoted 6 lines
Quoted 2 lines

Thanks,
Michael

Whoops, I missed that you removed the } that belongs to the enclosing if block. Probably because it is not properly indented in the original code.

Easy to miss because that bracket is in wrong place in first place.

Michael can you now on even build test before sending. Thanks.

Quoted 4 lines

Best regards,
Michael

#4 lore raw
Quoted 36 lines · Kari Argillander
Quoted 35 lines · Michael Straube
Quoted 33 lines · Michael Straube
Quoted 23 lines · Saurav Girepunje

Remove NULL check. NULL check before freeing function is not needed.

---
   drivers/staging/r8188eu/core/rtw_sta_mgt.c | 4 +---
   1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/r8188eu/core/rtw_sta_mgt.c +1 -3
index f6dffed53a60..4726771a8403 100644
@@ -155,9 +155,7 @@ u32    _rtw_free_sta_priv(struct    sta_priv
 *pstapriv)
           spin_unlock_bh(&pstapriv->sta_hash_lock);
           /*===============================*/
 
-        if (pstapriv->pallocated_stainfo_buf)
-            vfree(pstapriv->pallocated_stainfo_buf);
-        }
+        vfree(pstapriv->pallocated_stainfo_buf);
 
       return _SUCCESS;
Quoted 4 lines

  }

Signature · 1 line
2.32.0

Thanks,
Michael

Quoted 8 lines
Quoted 3 lines

Whoops, I missed that you removed the } that belongs to the enclosing if block. Probably because it is not properly indented in the original code.

Easy to miss because that bracket is in wrong place in first place.

Michael can you now on even build test before sending. Thanks.

Sure, I usually do. For this one I did not but obviously I should have.. ;)