Skip to content

Commit

Permalink
wifi: cfg80211: fix memory leak in query_regdb_file()
Browse files Browse the repository at this point in the history
[ Upstream commit 57b962e ]

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: 007f6c5 ("cfg80211: support loading regulatory database as firmware file")
Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Arend van Spriel authored and gregkh committed Nov 16, 2022
1 parent 11e6c69 commit e9b5a45
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions net/wireless/reg.c
Expand Up @@ -1084,6 +1084,8 @@ MODULE_FIRMWARE("regulatory.db");

static int query_regdb_file(const char *alpha2)
{
int err;

ASSERT_RTNL();

if (regdb)
Expand All @@ -1093,9 +1095,13 @@ static int query_regdb_file(const char *alpha2)
if (!alpha2)
return -ENOMEM;

return request_firmware_nowait(THIS_MODULE, true, "regulatory.db",
&reg_pdev->dev, GFP_KERNEL,
(void *)alpha2, regdb_fw_cb);
err = request_firmware_nowait(THIS_MODULE, true, "regulatory.db",
&reg_pdev->dev, GFP_KERNEL,
(void *)alpha2, regdb_fw_cb);
if (err)
kfree(alpha2);

return err;
}

int reg_reload_regdb(void)
Expand Down

0 comments on commit e9b5a45

Please sign in to comment.