mt7601u: null check the allocation
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Wed, 24 Jul 2019 14:17:36 +0000 (09:17 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Tue, 6 Aug 2019 12:35:28 +0000 (15:35 +0300)
devm_kzalloc may fail and return NULL. So the null check is needed.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Acked-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt7601u/init.c

index 9bfac9f1d47fe501e4a338d411787f013726d443..cada48800928f179dedddfc11307bf3b6e94d79e 100644 (file)
@@ -557,6 +557,9 @@ mt76_init_sband_2g(struct mt7601u_dev *dev)
 {
        dev->sband_2g = devm_kzalloc(dev->dev, sizeof(*dev->sband_2g),
                                     GFP_KERNEL);
+       if (!dev->sband_2g)
+               return -ENOMEM;
+
        dev->hw->wiphy->bands[NL80211_BAND_2GHZ] = dev->sband_2g;
 
        WARN_ON(dev->ee->reg.start - 1 + dev->ee->reg.num >