rtl8180: avoid NULL dereference in max2820_rf_set_channel
authorJohn W. Linville <linville@tuxdriver.com>
Tue, 27 May 2008 21:01:55 +0000 (17:01 -0400)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 28 May 2008 20:43:38 +0000 (16:43 -0400)
The static function max2820_rf_set_channel is called with conf == NULL
within its compilation unit.  Originally this defaulted to b/g channel
1, but "cfg80211 API for channels/bitrates, mac80211 and driver
conversion" (commit 8318d78a44d49ac1edf2bdec7299de3617c4232e) mistakenly
dropped this check.  This patch minimally restores the expected
behavior.

Reported-by: Colin Lai <colin_sh@163.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rtl8180_max2820.c

index a34dfd382b6df1470b766aec4bcb89fa73fa3d9b..a140c802264a70429b08343c25823d143b8ccb85 100644 (file)
@@ -78,7 +78,8 @@ static void max2820_rf_set_channel(struct ieee80211_hw *dev,
                                   struct ieee80211_conf *conf)
 {
        struct rtl8180_priv *priv = dev->priv;
-       int channel = ieee80211_frequency_to_channel(conf->channel->center_freq);
+       int channel = conf ?
+               ieee80211_frequency_to_channel(conf->channel->center_freq) : 1;
        unsigned int chan_idx = channel - 1;
        u32 txpw = priv->channels[chan_idx].hw_value & 0xFF;
        u32 chan = max2820_chan[chan_idx];