wifi: cfg80211: fix memory leak in query_regdb_file()
PATCH v2 1/1 wifi: cfg80211: fix memory leak in query_regdb_file()
In the function query_regdb_file() the alpha2 parameter is duplicated using kmemdup() and subsequently freed in regdb_fw_cb(). However, request_firmware_nowait() can fail without calling regdb_fw_cb() and thus leak memory.
Fixes 007f6c5e6eb4 ("cfg80211: support loading regulatory database as firmware file")
Signed-off-by Arend van Spriel <[email protected]>
---
Got a hint from Florian that previous patch had line wrapping hence this update. Also got sending emails using my work email going so changing indentities here.
Regards,
Arend
--- net/wireless/reg.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/wireless/reg.c +9 -3
@@ -1080,6 +1080,8 @@ static void regdb_fw_cb(const struct firmware *fw, void *context)static int query_regdb_file (const char *alpha2) { +int err; +ASSERT_RTNL ();if (regdb)
@@ -1089,9 +1091,13 @@ static int query_regdb_file(const char *alpha2)if (!alpha2)return -ENOMEM ; -return request_firmware_nowait (THIS_MODULE , true,"regulatory.db" , - ®_pdev->dev,GFP_KERNEL , - (void *)alpha2, regdb_fw_cb); + err =request_firmware_nowait (THIS_MODULE , true,"regulatory.db" , + ®_pdev->dev,GFP_KERNEL , + (void *)alpha2, regdb_fw_cb); +if (err) +kfree (alpha2); + +return err; }int reg_reload_regdb (void )
Signature · 1 line
2.35.1