Skip to content

Commit

Permalink
wifi: mt76: mt7921: Fix use-after-free in fw features query.
Browse files Browse the repository at this point in the history
Stop referencing 'features' memory after release_firmware is called.

Fixes this crash:

RIP: 0010:mt7921_check_offload_capability+0x17d
mt7921_pci_probe+0xca/0x4b0
...

Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Acked-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/51fd8f76494348aa9ecbf0abc471ebe47a983dfd.1679502607.git.lorenzo@kernel.org
  • Loading branch information
greearb authored and Kalle Valo committed Mar 31, 2023
1 parent e4efa51 commit 2ceb76f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/net/wireless/mediatek/mt76/mt7921/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,12 @@ mt7921_mac_init_band(struct mt7921_dev *dev, u8 band)

u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm)
{
struct mt7921_fw_features *features = NULL;
const struct mt76_connac2_fw_trailer *hdr;
struct mt7921_realease_info *rel_info;
const struct firmware *fw;
int ret, i, offset = 0;
const u8 *data, *end;
u8 offload_caps = 0;

ret = request_firmware(&fw, fw_wm, dev);
if (ret)
Expand Down Expand Up @@ -208,7 +208,10 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm)
data += sizeof(*rel_info);

if (rel_info->tag == MT7921_FW_TAG_FEATURE) {
struct mt7921_fw_features *features;

features = (struct mt7921_fw_features *)data;
offload_caps = features->data;
break;
}

Expand All @@ -218,7 +221,7 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm)
out:
release_firmware(fw);

return features ? features->data : 0;
return offload_caps;
}
EXPORT_SYMBOL_GPL(mt7921_check_offload_capability);

Expand Down

0 comments on commit 2ceb76f

Please sign in to comment.