Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails

From: Pavel Skripkin
Date: Fri Jan 07 2022 - 06:15:27 EST


Hi Michael,

On 1/7/22 13:36, Michael Straube wrote:
In function load_firmware() release_firmware() is not called if the
allocation of pFirmware->szFwBuffer fails or if fw->size is greater
than FW_8188E_SIZE.

Move the call to release_firmware() to the exit label at the end of
the function to fix this.

Signed-off-by: Michael Straube <straube.linux@xxxxxxxxx>
---
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index dc41682fd8d6..cfafbb6c42f7 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -538,10 +538,10 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
}
memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
pFirmware->ulFwLength = fw->size;
- release_firmware(fw);
dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", pFirmware->ulFwLength);
Exit:
+ release_firmware(fw);
return rtStatus;
}


This patch looks like a bug fix and it should go to stable kernels as well. The problem is this patch is made on top of 2 previous clean up patches, so it can't go to stable as is.

I think, the less painful way is to move this patch on the first place in this series. On the other hand you can just resend this one separately.


Or, maybe, Greg knows some magic that will help here, we can wait him before you resend 20 patch series :)

If you will somehow resend, please, add following tag:

Fixes: 8cd574e6af54 ("staging: r8188eu: introduce new hal dir for RTL8188eu driver")


Thanks for you clean up work on this driver!


With regards,
Pavel Skripkin