Re: [PATCH 12/12] staging: r8188eu: hal_data_sz is set but never used

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/5/21 15:42, Pavel Skripkin wrote:
On 12/5/21 16:59, Michael Straube wrote:
hal_data_sz in struct adapter is set but never used. Remove it.

Signed-off-by: Michael Straube <straube.linux@xxxxxxxxx>
---
  drivers/staging/r8188eu/hal/usb_halinit.c   | 1 -
  drivers/staging/r8188eu/include/drv_types.h | 1 -
  2 files changed, 2 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 641aaf299109..da966538596f 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -1969,5 +1969,4 @@ void rtl8188eu_alloc_haldata(struct adapter *adapt)
      adapt->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL);
      if (!adapt->HalData)
          DBG_88E("cant not alloc memory for HAL DATA\n");
-    adapt->hal_data_sz = sizeof(struct hal_data_8188e);
  }

Not related to your patch, but not returning an error from this function  looks very dangerous to me.

I agree.


adapt->HalData is used in GET_HAL_DATA() macro all across the driver code and nobody checks if it valid or not. If allocation fails here, than we will likely hit GPF while accessing hal_data fields.

Maybe we can embed struct hal_data_8188e instead of storing a pointer to it?




We could remove rtl8188eu_alloc_haldata() completely and replace its
usage in the function rtw_usb_if1_init().

--- a/drivers/staging/r8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/r8188eu/os_dep/usb_intf.c
@@ -362,7 +362,9 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj,
        padapter = rtw_netdev_priv(pnetdev);

        /* step 2. allocate HalData */
-       rtl8188eu_alloc_haldata(padapter);
+       padapter->HalData = kzalloc(sizeof(*padapter->HalData), GFP_KERNEL);
+       if (!padapter->HalData)
+               goto handle_dualmac;

This way rtw_drv_init() would return -ENODEV if the allocation fails.
What do you think?

Regards,
Michael




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux