ipw2200: check for allocation failures
authorDan Carpenter <error27@gmail.com>
Mon, 4 Oct 2010 12:31:46 +0000 (14:31 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 5 Oct 2010 17:35:29 +0000 (13:35 -0400)
If kzalloc() fails then return should return with -ENOMEM.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ipw2x00/ipw2200.c

index cb2552a6777c1a26573b5684320933486747d20c..d04d760827779c5bf0289e75985e66f4913bee47 100644 (file)
@@ -11470,6 +11470,10 @@ static int ipw_net_init(struct net_device *dev)
                bg_band->channels =
                        kzalloc(geo->bg_channels *
                                sizeof(struct ieee80211_channel), GFP_KERNEL);
+               if (!bg_band->channels) {
+                       rc = -ENOMEM;
+                       goto out;
+               }
                /* translate geo->bg to bg_band.channels */
                for (i = 0; i < geo->bg_channels; i++) {
                        bg_band->channels[i].band = IEEE80211_BAND_2GHZ;
@@ -11505,6 +11509,10 @@ static int ipw_net_init(struct net_device *dev)
                a_band->channels =
                        kzalloc(geo->a_channels *
                                sizeof(struct ieee80211_channel), GFP_KERNEL);
+               if (!a_band->channels) {
+                       rc = -ENOMEM;
+                       goto out;
+               }
                /* translate geo->bg to a_band.channels */
                for (i = 0; i < geo->a_channels; i++) {
                        a_band->channels[i].band = IEEE80211_BAND_2GHZ;