提交 e365f160 编写于 作者: C Christian Lamparter 提交者: John W. Linville

p54: prevent upload of wrong firmwares

This patch will prevent anyone to upload a firmware which was not designed for his device.

There's still a catch:
There is no easy way to detect if a firmware is for PCI or for USB (1st Gen),
because they all share the same LM86 identifier.
Signed-off-by: NChristian Lamparter <chunkeey@web.de>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 6982869d
...@@ -79,6 +79,12 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev) ...@@ -79,6 +79,12 @@ static int p54p_upload_firmware(struct ieee80211_hw *dev)
if (err) if (err)
return err; return err;
if (priv->common.fw_interface != FW_LM86) {
dev_err(&priv->pdev->dev, "wrong firmware, "
"please get a LM86(PCI) firmware a try again.\n");
return -EINVAL;
}
data = (__le32 *) priv->firmware->data; data = (__le32 *) priv->firmware->data;
remains = priv->firmware->size; remains = priv->firmware->size;
device_addr = ISL38XX_DEV_FIRMWARE_ADDR; device_addr = ISL38XX_DEV_FIRMWARE_ADDR;
......
...@@ -498,6 +498,13 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev) ...@@ -498,6 +498,13 @@ static int p54u_upload_firmware_3887(struct ieee80211_hw *dev)
if (err) if (err)
goto err_upload_failed; goto err_upload_failed;
if (priv->common.fw_interface != FW_LM87) {
dev_err(&priv->udev->dev, "wrong firmware, "
"please get a LM87 firmware and try again.\n");
err = -EINVAL;
goto err_upload_failed;
}
left = block_size = min((size_t)P54U_FW_BLOCK, fw_entry->size); left = block_size = min((size_t)P54U_FW_BLOCK, fw_entry->size);
strcpy(buf, p54u_firmware_upload_3887); strcpy(buf, p54u_firmware_upload_3887);
left -= strlen(p54u_firmware_upload_3887); left -= strlen(p54u_firmware_upload_3887);
...@@ -648,6 +655,14 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev) ...@@ -648,6 +655,14 @@ static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
return err; return err;
} }
if (priv->common.fw_interface != FW_LM86) {
dev_err(&priv->udev->dev, "wrong firmware, "
"please get a LM86(USB) firmware and try again.\n");
kfree(buf);
release_firmware(fw_entry);
return -EINVAL;
}
#define P54U_WRITE(type, addr, data) \ #define P54U_WRITE(type, addr, data) \
do {\ do {\
err = p54u_write(priv, buf, type,\ err = p54u_write(priv, buf, type,\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册