staging: r888eu: use dynamic allocation for efuse buffer
authorMartin Kaiser <martin@kaiser.cx>
Wed, 13 Jul 2022 07:58:04 +0000 (09:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 14 Jul 2022 13:47:21 +0000 (15:47 +0200)
Use kmalloc to allocate the efuse buffer in ReadAdapterInfo8188EU and
free it on exit. This is better than using a 512 byte array on the stack.

It's ok to drop the __aligned(4) qualifier. kmalloc aligns to
ARCH_KMALLOC_MINALIGN, this is at least 8 bytes.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Larry Finger <Larry.Finger@lwfinger.net>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
Link: https://lore.kernel.org/r/20220713075804.140986-1-martin@kaiser.cx
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/hal/usb_halinit.c

index 68d012a442a8d3c46b8b13abe96e4fd327c1b9a1..695424bbecfc15784a648cd3bd925765b83917c8 100644 (file)
@@ -927,7 +927,7 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter)
 {
        struct eeprom_priv *eeprom = &Adapter->eeprompriv;
        struct led_priv *ledpriv = &Adapter->ledpriv;
-       u8 efuse_buf[EFUSE_MAP_LEN_88E] __aligned(4);
+       u8 *efuse_buf;
        u8 eeValue;
        int res;
 
@@ -938,7 +938,10 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter)
 
        eeprom->bautoload_fail_flag     = !(eeValue & EEPROM_EN);
 
-       memset(efuse_buf, 0xFF, sizeof(efuse_buf));
+       efuse_buf = kmalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL);
+       if (!efuse_buf)
+               return;
+       memset(efuse_buf, 0xFF, EFUSE_MAP_LEN_88E);
 
        if (!(eeValue & BOOT_FROM_EEPROM) && !eeprom->bautoload_fail_flag) {
                rtl8188e_EfusePowerSwitch(Adapter, true);
@@ -958,6 +961,7 @@ void ReadAdapterInfo8188EU(struct adapter *Adapter)
        Hal_ReadThermalMeter_88E(Adapter, efuse_buf, eeprom->bautoload_fail_flag);
 
        ledpriv->bRegUseLed = true;
+       kfree(efuse_buf);
 }
 
 static void ResumeTxBeacon(struct adapter *adapt)