Commit c3afd99f authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

mwifiex: fix adapter pointer dereference issue

It has introduced by recent commit 6b41f941: "mwifiex:
handle driver initialization error paths" which adds error
path handling for mwifiex_fw_dpc().

release_firmware(adapter->*) is called for success as well
as failure paths. In failure paths, adapter is already freed
at this point.

The issue is fixed by moving mwifiex_free_adapter() call.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7546ff95
...@@ -414,6 +414,8 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) ...@@ -414,6 +414,8 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
struct mwifiex_private *priv; struct mwifiex_private *priv;
struct mwifiex_adapter *adapter = context; struct mwifiex_adapter *adapter = context;
struct mwifiex_fw_image fw; struct mwifiex_fw_image fw;
struct semaphore *sem = adapter->card_sem;
bool init_failed = false;
if (!firmware) { if (!firmware) {
dev_err(adapter->dev, dev_err(adapter->dev,
...@@ -528,15 +530,20 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context) ...@@ -528,15 +530,20 @@ static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
} }
adapter->surprise_removed = true; adapter->surprise_removed = true;
mwifiex_terminate_workqueue(adapter); mwifiex_terminate_workqueue(adapter);
mwifiex_free_adapter(adapter); init_failed = true;
done: done:
if (adapter->cal_data) { if (adapter->cal_data) {
release_firmware(adapter->cal_data); release_firmware(adapter->cal_data);
adapter->cal_data = NULL; adapter->cal_data = NULL;
} }
if (adapter->firmware) {
release_firmware(adapter->firmware); release_firmware(adapter->firmware);
adapter->firmware = NULL;
}
complete(&adapter->fw_load); complete(&adapter->fw_load);
up(adapter->card_sem); if (init_failed)
mwifiex_free_adapter(adapter);
up(sem);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment