[PATCH] orinoco: possible null pointer dereference in orinoco_rx_monitor()
[cascardo/linux.git] / drivers / net / wireless / orinoco.c
index 70a3477..c2d0b09 100644 (file)
@@ -390,7 +390,7 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev)
                }
        } else {
                struct {
-                       __le16 qual, signal, noise;
+                       __le16 qual, signal, noise, unused;
                } __attribute__ ((packed)) cq;
 
                err = HERMES_READ_RECORD(hw, USER_BAP,
@@ -542,14 +542,21 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev)
                        stats->tx_errors++;
                        goto fail;
                }
+               /* Actual xfer length - allow for padding */
+               len = ALIGN(data_len, 2);
+               if (len < ETH_ZLEN - ETH_HLEN)
+                       len = ETH_ZLEN - ETH_HLEN;
        } else { /* IEEE 802.3 frame */
                data_len = len + ETH_HLEN;
                data_off = HERMES_802_3_OFFSET;
                p = skb->data;
+               /* Actual xfer length - round up for odd length packets */
+               len = ALIGN(data_len, 2);
+               if (len < ETH_ZLEN)
+                       len = ETH_ZLEN;
        }
 
-       /* Round up for odd length packets */
-       err = hermes_bap_pwrite(hw, USER_BAP, p, ALIGN(data_len, 2),
+       err = hermes_bap_pwrite_pad(hw, USER_BAP, p, data_len, len,
                                txfid, data_off);
        if (err) {
                printk(KERN_ERR "%s: Error %d writing packet to BAP\n",
@@ -805,7 +812,6 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
        if (datalen > IEEE80211_DATA_LEN + 12) {
                printk(KERN_DEBUG "%s: oversized monitor frame, "
                       "data length = %d\n", dev->name, datalen);
-               err = -EIO;
                stats->rx_length_errors++;
                goto update_stats;
        }
@@ -814,8 +820,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid,
        if (!skb) {
                printk(KERN_WARNING "%s: Cannot allocate skb for monitor frame\n",
                       dev->name);
-               err = -ENOMEM;
-               goto drop;
+               goto update_stats;
        }
 
        /* Copy the 802.11 header to the skb */
@@ -3505,9 +3510,8 @@ static int orinoco_ioctl_setpower(struct net_device *dev,
                        break;
                default:
                        err = -EINVAL;
-               }
-               if (err)
                        goto out;
+               }
                
                if (prq->flags & IW_POWER_TIMEOUT) {
                        priv->pm_on = 1;
@@ -3852,7 +3856,7 @@ static int orinoco_ioctl_setscan(struct net_device *dev,
        unsigned long flags;
 
        /* Note : you may have realised that, as this is a SET operation,
-        * this is priviledged and therefore a normal user can't
+        * this is privileged and therefore a normal user can't
         * perform scanning.
         * This is not an error, while the device perform scanning,
         * traffic doesn't flow, so it's a perfect DoS...