@@ -171,6 +171,7 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm)
const struct firmware *fw;
int ret, i, offset = 0;
const u8 *data, *end;
+ u8 rv = 0;
ret = request_firmware(&fw, fw_wm, dev);
if (ret)
@@ -197,12 +198,17 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm)
data += sizeof(*rel_info);
end = data + le16_to_cpu(rel_info->len);
+ /* TODO: This needs better sanity checking I think.
+ * Likely a corrupted firmware with bad rel_info->len, for instance,
+ * would blow this up.
+ */
while (data < end) {
rel_info = (struct mt7921_realease_info *)data;
data += sizeof(*rel_info);
if (rel_info->tag == MT7921_FW_TAG_FEATURE) {
features = (struct mt7921_fw_features *)data;
+ rv = features->data;
break;
}
@@ -211,7 +217,7 @@ u8 mt7921_check_offload_capability(struct device *dev, const char *fw_wm)
release_firmware(fw);
- return features ? features->data : 0;
+ return rv;
}
EXPORT_SYMBOL_GPL(mt7921_check_offload_capability);