From: Christian Lamparter <chunkeey@web.de>
To: linux-wireless@vger.kernel.org
Cc: John W Linville <linville@tuxdriver.com>,
Larry Finger <Larry.Finger@lwfinger.net>,
Pavel Roskin <proski@gnu.org>
Subject: [PATCH 3/4] p54: protect against sudden firmware file changes
Date: Fri, 14 Nov 2008 19:41:56 +0100 [thread overview]
Message-ID: <200811141941.56752.chunkeey@web.de> (raw)
Thanks to "p54: introduce new names for device firmwares"
(325ca16910a380c...) people are now migrating away from the buggy firmwares.
Of course this is a very good idea, but no one told them to unload the driver first.
Signed-off-by: Christian Lamparter <chunkeey@web.de>
---
diff -Nurp a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
--- a/drivers/net/wireless/p54/p54common.c 2008-11-14 18:08:22.000000000 +0100
+++ b/drivers/net/wireless/p54/p54common.c 2008-11-14 18:12:15.000000000 +0100
@@ -19,6 +19,7 @@
#include <linux/init.h>
#include <linux/firmware.h>
#include <linux/etherdevice.h>
+#include <linux/crc32.h>
#include <net/mac80211.h>
@@ -132,12 +133,22 @@ int p54_parse_firmware(struct ieee80211_
struct bootrec *bootrec;
u32 *data = (u32 *)fw->data;
u32 *end_data = (u32 *)fw->data + (fw->size >> 2);
+ u32 crc = crc32_le(~0, (void *)data, fw->size >> 2);
u8 *fw_version = NULL;
size_t len;
int i;
- if (priv->rx_start)
- return 0;
+ if (priv->fw_crc) {
+ if (priv->fw_crc == crc)
+ return 0;
+
+ printk(KERN_ERR "%s: DO NOT (ex)change firmware files while "
+ "the driver is loaded. This device is now "
+ "disabled. Please reload the driver, "
+ "if you want it back!",
+ wiphy_name(dev->wiphy));
+ return -EINVAL;
+ }
while (data < end_data && *data)
data++;
@@ -227,6 +238,7 @@ int p54_parse_firmware(struct ieee80211_
priv->tx_stats[7].limit = 2; /* AC_BK */
dev->queues = 4;
}
+ priv->fw_crc = crc;
return 0;
}
@@ -1525,16 +1537,24 @@ static int p54_start(struct ieee80211_hw
mutex_lock(&priv->conf_mutex);
err = priv->open(dev);
- if (!err)
- priv->mode = NL80211_IFTYPE_MONITOR;
+ if (err)
+ goto out;
P54_SET_QUEUE(priv->qos_params[0], 0x0002, 0x0003, 0x0007, 47);
P54_SET_QUEUE(priv->qos_params[1], 0x0002, 0x0007, 0x000f, 94);
P54_SET_QUEUE(priv->qos_params[2], 0x0003, 0x000f, 0x03ff, 0);
P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0);
err = p54_set_edcf(dev);
- if (!err)
- err = p54_init_stats(dev);
+ if (err)
+ goto out;
+ err = p54_init_stats(dev);
+ if (err)
+ goto out;
+ err = p54_setup_mac(dev, P54_FILTER_TYPE_NONE, NULL);
+ if (err)
+ goto out;
+ priv->mode = NL80211_IFTYPE_MONITOR;
+out:
mutex_unlock(&priv->conf_mutex);
return err;
}
diff -Nurp a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
--- a/drivers/net/wireless/p54/p54.h 2008-11-14 00:14:59.000000000 +0100
+++ b/drivers/net/wireless/p54/p54.h 2008-11-05 23:31:28.000000000 +0100
@@ -73,6 +73,7 @@ struct p54_edcf_queue_param {
struct p54_common {
u32 rx_start;
u32 rx_end;
+ u32 fw_crc;
struct sk_buff_head tx_queue;
void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb,
int free_on_tx);
next reply other threads:[~2008-11-14 18:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-14 18:41 Christian Lamparter [this message]
2008-11-14 22:00 ` [PATCH 3/4] p54: protect against sudden firmware file changes Johannes Berg
2008-11-14 23:54 ` Christian Lamparter
2008-11-15 0:02 ` Johannes Berg
2008-11-15 0:42 ` [PATCH 3/4] p54pci: cache firmware for suspend/resume Christian Lamparter
2008-11-15 18:30 ` [PATCH 3/4] p54pci: cache firmware for suspend/resume v2 Christian Lamparter
2008-11-16 11:20 ` [PATCH 3/4] p54pci: cache firmware for suspend/resume v2.1 Christian Lamparter
2008-11-16 15:35 ` Larry Finger
2008-11-16 15:36 ` Johannes Berg
2008-11-15 0:35 ` [PATCH 3/4] p54: protect against sudden firmware file changes Luis R. Rodriguez
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200811141941.56752.chunkeey@web.de \
--to=chunkeey@web.de \
--cc=Larry.Finger@lwfinger.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=proski@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).