Commit 57b962e6 authored by Arend van Spriel's avatar Arend van Spriel Committed by Johannes Berg

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: 007f6c5e ("cfg80211: support loading regulatory database as firmware file")
Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 50b2e871
...@@ -1084,6 +1084,8 @@ MODULE_FIRMWARE("regulatory.db"); ...@@ -1084,6 +1084,8 @@ MODULE_FIRMWARE("regulatory.db");
static int query_regdb_file(const char *alpha2) static int query_regdb_file(const char *alpha2)
{ {
int err;
ASSERT_RTNL(); ASSERT_RTNL();
if (regdb) if (regdb)
...@@ -1093,9 +1095,13 @@ static int query_regdb_file(const char *alpha2) ...@@ -1093,9 +1095,13 @@ static int query_regdb_file(const char *alpha2)
if (!alpha2) if (!alpha2)
return -ENOMEM; return -ENOMEM;
return request_firmware_nowait(THIS_MODULE, true, "regulatory.db", err = request_firmware_nowait(THIS_MODULE, true, "regulatory.db",
&reg_pdev->dev, GFP_KERNEL, &reg_pdev->dev, GFP_KERNEL,
(void *)alpha2, regdb_fw_cb); (void *)alpha2, regdb_fw_cb);
if (err)
kfree(alpha2);
return err;
} }
int reg_reload_regdb(void) int reg_reload_regdb(void)
......
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