mwifiex: fix potential null dereference 'mef_entry'
authorBing Zhao <bzhao@marvell.com>
Thu, 7 Mar 2013 00:44:26 +0000 (16:44 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 8 Mar 2013 21:02:48 +0000 (16:02 -0500)
drivers/net/wireless/mwifiex/cfg80211.c:2357 mwifiex_cfg80211_suspend()
  error: potential null dereference 'mef_entry'
  (kzalloc returns null)

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cfg80211.c

index df30107225f82b11c7fd47776daa4ee9e628e29f..c9bc5f5ba6e13795acc1a4cde00e894506fb7883 100644 (file)
@@ -2350,9 +2350,12 @@ static int mwifiex_cfg80211_suspend(struct wiphy *wiphy,
                return 0;
        }
 
+       mef_entry = kzalloc(sizeof(*mef_entry), GFP_KERNEL);
+       if (!mef_entry)
+               return -ENOMEM;
+
        memset(&mef_cfg, 0, sizeof(mef_cfg));
        mef_cfg.num_entries = 1;
-       mef_entry = kzalloc(sizeof(*mef_entry), GFP_KERNEL);
        mef_cfg.mef_entry = mef_entry;
        mef_entry->mode = MEF_MODE_HOST_SLEEP;
        mef_entry->action = MEF_ACTION_ALLOW_AND_WAKEUP_HOST;