staging: ks7010: return on failure
PATCH 1/2 staging: ks7010: return on failure
On failure we were jumping to error_out0 where we were trying sdio_release_host() but at this point of execution we still have not done sdio_claim_host() and as a result host->claimed can still be 0. And if host->claimed is 0 then WARN_ON(!host->claimed) will give a warning.
Moreover, if it is still not claimed then mmc_host->claim_cnt will be 0 and mmc_release_host() will do "if (--host->claim_cnt)" and thus the condition will become true.
Lets just return the value on allocation failure instead of trying to release the host before claiming it.
--- drivers/staging/ks7010/ks7010_sdio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/ks7010/ks7010_sdio.c +2 -4
@@ -776,10 +776,8 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv,/* buffer allocate */ rom_buf =kmalloc (ROM_BUFF_SIZE ,GFP_KERNEL ); -if (!rom_buf) { - rc =3 ; - goto error_out0; - } +if (!rom_buf) +return 3 ;sdio_claim_host (card->func);
Signature · 1 line
1.9.1
PATCH 2/2 staging: ks7010: fix memory leak
If the firmware request failed we were just returning but we missed freeing the memory and releasing the MMC Host.
--- drivers/staging/ks7010/ks7010_sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/ks7010/ks7010_sdio.c +1 -1
@@ -791,7 +791,7 @@ static int ks7010_upload_firmware(struct ks_wlan_private *priv, retval =request_firmware (&fw_entry,ROM_FILE , &priv->ks_wlan_hw.sdio_card->func->dev);if (retval) -return retval; + goto error_out0; length = fw_entry->size;
Signature · 1 line
1.9.1
Greg Kroah-Hartman
maintainerQuoted 11 lines · Sudip Mukherjee
On failure we were jumping to
error_out0where we were tryingsdio_release_host()but at this point of execution we still have not donesdio_claim_host()and as a resulthost->claimedcan still be 0. And ifhost->claimedis 0 thenWARN_ON(!host->claimed)will give a warning.
Moreover, if it is still not claimed thenmmc_host->claim_cntwill be 0 andmmc_release_host()will do "if (--host->claim_cnt)" and thus the condition will become true.
Lets just return the value on allocation failure instead of trying to release the host before claiming it.
Quoted 4 lines
Signed-off-by Sudip Mukherjee <[email protected]>--- drivers/staging/ks7010/ks7010_sdio.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
Please always cc: the maintainer of the driver when you send patches in.
Please fix that up and resend these 2 patches.
thanks,
greg k-h