Fix for division by zero.

MFC after:	3 days
This commit is contained in:
hselasky 2014-07-26 16:06:01 +00:00
parent 7f656072ad
commit 4600967ac6
4 changed files with 6 additions and 2 deletions

View File

@ -1035,6 +1035,8 @@ rum_setup_tx_desc(struct rum_softc *sc, struct rum_tx_desc *desc,
desc->plcp_length_hi = plcp_length >> 6;
desc->plcp_length_lo = plcp_length & 0x3f;
} else {
if (rate == 0)
rate = 2; /* avoid division by zero */
plcp_length = (16 * len + rate - 1) / rate;
if (rate == 22) {
remainder = (16 * len) % 22;

View File

@ -1038,6 +1038,8 @@ ural_setup_tx_desc(struct ural_softc *sc, struct ural_tx_desc *desc,
desc->plcp_length_hi = plcp_length >> 6;
desc->plcp_length_lo = plcp_length & 0x3f;
} else {
if (rate == 0)
rate = 2; /* avoid division by zero */
plcp_length = (16 * len + rate - 1) / rate;
if (rate == 22) {
remainder = (16 * len) % 22;

View File

@ -2480,7 +2480,7 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
const struct ieee80211_txparam *tp;
struct ieee80211_key *k;
int rate, totlen;
static uint8_t ratediv[] = ZYD_TX_RATEDIV;
static const uint8_t ratediv[] = ZYD_TX_RATEDIV;
uint8_t phy;
uint16_t pktlen;
uint32_t bits;

View File

@ -970,7 +970,7 @@
#define ZYD_TX_RATEDIV \
{ \
0x1, 0x2, 0xb, 0xb, 0x0, 0x0, 0x0, 0x0, 0x30, 0x18, 0xc, 0x6, \
0x1, 0x2, 0xb, 0xb, 0x1, 0x1, 0x1, 0x1, 0x30, 0x18, 0xc, 0x6, \
0x36, 0x24, 0x12, 0x9 \
}