[PATCH wireless-next 3/3] wifi: nxpwifi: release the firmware when the VDLL image does not fit

Linmao Li <[email protected]>
Newsgroups org.kernel.vger.linux-wireless,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
nxpwifi_get_vdll_image() requests the firmware file when the driver no
longer holds it and drops that reference once the image has been
copied.  The error path taken when the requested VDLL length is not
smaller than the firmware returns without dropping it, and nothing else
releases adapter->firmware after the initial download completes, so the
whole firmware image stays pinned for the lifetime of the adapter.

Release it on that path too.

Fixes: 73b01e57ed3e ("wifi: nxp: add nxpwifi driver for IW61x")
Signed-off-by: Linmao Li <[email protected]>
---
 drivers/net/wireless/nxp/nxpwifi/util.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/wireless/nxp/nxpwifi/util.c b/drivers/net/wireless/nxp/nxpwifi/util.c
index 97811ee25f392..1d664967ca854 100644
--- a/drivers/net/wireless/nxp/nxpwifi/util.c
+++ b/drivers/net/wireless/nxp/nxpwifi/util.c
@@ -1206,6 +1206,10 @@ static int nxpwifi_get_vdll_image(struct nxpwifi_adapter *adapter, u32 vdll_len)
 			nxpwifi_dbg(adapter, ERROR,
 				    "Invalid VDLL length = %d, fw_len=%d\n",
 				    vdll_len, (int)adapter->firmware->size);
+			if (req_fw) {
+				release_firmware(adapter->firmware);
+				adapter->firmware = NULL;
+			}
 			return -EINVAL;
 		}
 		if (req_fw) {
-- 
2.25.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.