All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] iwlwifi: pnvm: fix resource leaks in iwl_pnvm_get_from_fs
@ 2021-05-08 11:09 wangyunjian
  0 siblings, 0 replies; only message in thread
From: wangyunjian @ 2021-05-08 11:09 UTC (permalink / raw)
  To: kuba, davem
  Cc: luciano.coelho, linux-wireless, netdev, dingxiaoxiong, Yunjian Wang

From: Yunjian Wang <wangyunjian@huawei.com>

Currently the error return path does not release the "pnvm" when
kmemdup fails and also the "pnvm" is not relased in the normal
path. These lead to a resource leak. Fix these by releasing "pnvm"
before return.

Addresses-Coverity: ("Resource leak")
Fixes: cdda18fbbefa ("iwlwifi: pnvm: move file loading code to a separate function")
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index 40f2109a097f..d4ac83848926 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -322,10 +322,13 @@ static int iwl_pnvm_get_from_fs(struct iwl_trans *trans, u8 **data, size_t *len)
 	}
 
 	*data = kmemdup(pnvm->data, pnvm->size, GFP_KERNEL);
-	if (!*data)
+	if (!*data) {
+		release_firmware(pnvm);
 		return -ENOMEM;
+	}
 
 	*len = pnvm->size;
+	release_firmware(pnvm);
 
 	return 0;
 }
-- 
2.19.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-08 11:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08 11:09 [PATCH net] iwlwifi: pnvm: fix resource leaks in iwl_pnvm_get_from_fs wangyunjian

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.