diff options
author | Joe Perches <joe@perches.com> | 2010-08-11 03:02:48 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-17 20:45:14 -0400 |
commit | baeb2ffab4e67bb9174e6166e070a9a8ec94b0f6 (patch) | |
tree | 08259e966cc0cacc58ed58a4865fe861cc255241 /drivers/net/wireless | |
parent | 5a68d5ee000bb784c4856391b4861739c8bbd341 (diff) |
drivers/net: Convert unbounded kzalloc calls to kcalloc
These changes may be slightly safer in some instances.
There are other kzalloc calls with a multiply, but those
calls are typically "small fixed #" * sizeof(some pointer)"
and those are not converted.
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/airo.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/b43/phy_n.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/ipw2x00/ipw2100.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/ipw2x00/ipw2200.c | 12 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2400pci.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500pci.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2500usb.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00debug.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00queue.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt61pci.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt73usb.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_scan.c | 2 |
13 files changed, 22 insertions, 23 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 1d05445d4ba3..7d26506957d7 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -2723,9 +2723,8 @@ static int airo_networks_allocate(struct airo_info *ai) | |||
2723 | if (ai->networks) | 2723 | if (ai->networks) |
2724 | return 0; | 2724 | return 0; |
2725 | 2725 | ||
2726 | ai->networks = | 2726 | ai->networks = kcalloc(AIRO_MAX_NETWORK_COUNT, sizeof(BSSListElement), |
2727 | kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), | 2727 | GFP_KERNEL); |
2728 | GFP_KERNEL); | ||
2729 | if (!ai->networks) { | 2728 | if (!ai->networks) { |
2730 | airo_print_warn("", "Out of memory allocating beacons"); | 2729 | airo_print_warn("", "Out of memory allocating beacons"); |
2731 | return -ENOMEM; | 2730 | return -ENOMEM; |
diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 5a725703770c..e288c559481d 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c | |||
@@ -1182,7 +1182,7 @@ static u16 b43_nphy_gen_load_samples(struct b43_wldev *dev, u32 freq, u16 max, | |||
1182 | len = bw << 1; | 1182 | len = bw << 1; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | samples = kzalloc(len * sizeof(struct b43_c32), GFP_KERNEL); | 1185 | samples = kcalloc(len, sizeof(struct b43_c32), GFP_KERNEL); |
1186 | if (!samples) { | 1186 | if (!samples) { |
1187 | b43err(dev->wl, "allocation for samples generation failed\n"); | 1187 | b43err(dev->wl, "allocation for samples generation failed\n"); |
1188 | return 0; | 1188 | return 0; |
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c index 1189dbb6e2a6..0c67b172d4c6 100644 --- a/drivers/net/wireless/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/ipw2x00/ipw2100.c | |||
@@ -1921,9 +1921,9 @@ static int ipw2100_net_init(struct net_device *dev) | |||
1921 | 1921 | ||
1922 | bg_band->band = IEEE80211_BAND_2GHZ; | 1922 | bg_band->band = IEEE80211_BAND_2GHZ; |
1923 | bg_band->n_channels = geo->bg_channels; | 1923 | bg_band->n_channels = geo->bg_channels; |
1924 | bg_band->channels = | 1924 | bg_band->channels = kcalloc(geo->bg_channels, |
1925 | kzalloc(geo->bg_channels * | 1925 | sizeof(struct ieee80211_channel), |
1926 | sizeof(struct ieee80211_channel), GFP_KERNEL); | 1926 | GFP_KERNEL); |
1927 | if (!bg_band->channels) { | 1927 | if (!bg_band->channels) { |
1928 | ipw2100_down(priv); | 1928 | ipw2100_down(priv); |
1929 | return -ENOMEM; | 1929 | return -ENOMEM; |
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index cb2552a6777c..0f2508384c75 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -11467,9 +11467,9 @@ static int ipw_net_init(struct net_device *dev) | |||
11467 | 11467 | ||
11468 | bg_band->band = IEEE80211_BAND_2GHZ; | 11468 | bg_band->band = IEEE80211_BAND_2GHZ; |
11469 | bg_band->n_channels = geo->bg_channels; | 11469 | bg_band->n_channels = geo->bg_channels; |
11470 | bg_band->channels = | 11470 | bg_band->channels = kcalloc(geo->bg_channels, |
11471 | kzalloc(geo->bg_channels * | 11471 | sizeof(struct ieee80211_channel), |
11472 | sizeof(struct ieee80211_channel), GFP_KERNEL); | 11472 | GFP_KERNEL); |
11473 | /* translate geo->bg to bg_band.channels */ | 11473 | /* translate geo->bg to bg_band.channels */ |
11474 | for (i = 0; i < geo->bg_channels; i++) { | 11474 | for (i = 0; i < geo->bg_channels; i++) { |
11475 | bg_band->channels[i].band = IEEE80211_BAND_2GHZ; | 11475 | bg_band->channels[i].band = IEEE80211_BAND_2GHZ; |
@@ -11502,9 +11502,9 @@ static int ipw_net_init(struct net_device *dev) | |||
11502 | 11502 | ||
11503 | a_band->band = IEEE80211_BAND_5GHZ; | 11503 | a_band->band = IEEE80211_BAND_5GHZ; |
11504 | a_band->n_channels = geo->a_channels; | 11504 | a_band->n_channels = geo->a_channels; |
11505 | a_band->channels = | 11505 | a_band->channels = kcalloc(geo->a_channels, |
11506 | kzalloc(geo->a_channels * | 11506 | sizeof(struct ieee80211_channel), |
11507 | sizeof(struct ieee80211_channel), GFP_KERNEL); | 11507 | GFP_KERNEL); |
11508 | /* translate geo->bg to a_band.channels */ | 11508 | /* translate geo->bg to a_band.channels */ |
11509 | for (i = 0; i < geo->a_channels; i++) { | 11509 | for (i = 0; i < geo->a_channels; i++) { |
11510 | a_band->channels[i].band = IEEE80211_BAND_2GHZ; | 11510 | a_band->channels[i].band = IEEE80211_BAND_2GHZ; |
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 5063e01410e5..8e3fbdf48889 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -1481,7 +1481,7 @@ static int rt2400pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1481 | /* | 1481 | /* |
1482 | * Create channel information array | 1482 | * Create channel information array |
1483 | */ | 1483 | */ |
1484 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | 1484 | info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); |
1485 | if (!info) | 1485 | if (!info) |
1486 | return -ENOMEM; | 1486 | return -ENOMEM; |
1487 | 1487 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index c2a555d5376b..1d174e42f11e 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -1795,7 +1795,7 @@ static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1795 | /* | 1795 | /* |
1796 | * Create channel information array | 1796 | * Create channel information array |
1797 | */ | 1797 | */ |
1798 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | 1798 | info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); |
1799 | if (!info) | 1799 | if (!info) |
1800 | return -ENOMEM; | 1800 | return -ENOMEM; |
1801 | 1801 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index cdaf93f48263..8ddaae44d7fb 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -1698,7 +1698,7 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
1698 | /* | 1698 | /* |
1699 | * Create channel information array | 1699 | * Create channel information array |
1700 | */ | 1700 | */ |
1701 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | 1701 | info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); |
1702 | if (!info) | 1702 | if (!info) |
1703 | return -ENOMEM; | 1703 | return -ENOMEM; |
1704 | 1704 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index b66e0fd8f0fa..8c00fbda8664 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -2865,7 +2865,7 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2865 | /* | 2865 | /* |
2866 | * Create channel information array | 2866 | * Create channel information array |
2867 | */ | 2867 | */ |
2868 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | 2868 | info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); |
2869 | if (!info) | 2869 | if (!info) |
2870 | return -ENOMEM; | 2870 | return -ENOMEM; |
2871 | 2871 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00debug.c b/drivers/net/wireless/rt2x00/rt2x00debug.c index b0498e7e7aae..2d018ceffc54 100644 --- a/drivers/net/wireless/rt2x00/rt2x00debug.c +++ b/drivers/net/wireless/rt2x00/rt2x00debug.c | |||
@@ -333,7 +333,7 @@ static ssize_t rt2x00debug_read_queue_stats(struct file *file, | |||
333 | if (*offset) | 333 | if (*offset) |
334 | return 0; | 334 | return 0; |
335 | 335 | ||
336 | data = kzalloc(lines * MAX_LINE_LENGTH, GFP_KERNEL); | 336 | data = kcalloc(lines, MAX_LINE_LENGTH, GFP_KERNEL); |
337 | if (!data) | 337 | if (!data) |
338 | return -ENOMEM; | 338 | return -ENOMEM; |
339 | 339 | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c index a3401d301058..9c609be95083 100644 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c | |||
@@ -755,7 +755,7 @@ static int rt2x00queue_alloc_entries(struct data_queue *queue, | |||
755 | * Allocate all queue entries. | 755 | * Allocate all queue entries. |
756 | */ | 756 | */ |
757 | entry_size = sizeof(*entries) + qdesc->priv_size; | 757 | entry_size = sizeof(*entries) + qdesc->priv_size; |
758 | entries = kzalloc(queue->limit * entry_size, GFP_KERNEL); | 758 | entries = kcalloc(queue->limit, entry_size, GFP_KERNEL); |
759 | if (!entries) | 759 | if (!entries) |
760 | return -ENOMEM; | 760 | return -ENOMEM; |
761 | 761 | ||
@@ -891,7 +891,7 @@ int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev) | |||
891 | */ | 891 | */ |
892 | rt2x00dev->data_queues = 2 + rt2x00dev->ops->tx_queues + req_atim; | 892 | rt2x00dev->data_queues = 2 + rt2x00dev->ops->tx_queues + req_atim; |
893 | 893 | ||
894 | queue = kzalloc(rt2x00dev->data_queues * sizeof(*queue), GFP_KERNEL); | 894 | queue = kcalloc(rt2x00dev->data_queues, sizeof(*queue), GFP_KERNEL); |
895 | if (!queue) { | 895 | if (!queue) { |
896 | ERROR(rt2x00dev, "Queue allocation failed.\n"); | 896 | ERROR(rt2x00dev, "Queue allocation failed.\n"); |
897 | return -ENOMEM; | 897 | return -ENOMEM; |
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index e539c6cb636f..f226582dbc87 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -2654,7 +2654,7 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2654 | /* | 2654 | /* |
2655 | * Create channel information array | 2655 | * Create channel information array |
2656 | */ | 2656 | */ |
2657 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | 2657 | info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); |
2658 | if (!info) | 2658 | if (!info) |
2659 | return -ENOMEM; | 2659 | return -ENOMEM; |
2660 | 2660 | ||
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index aa9de18fd410..99985a218653 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -2084,7 +2084,7 @@ static int rt73usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2084 | /* | 2084 | /* |
2085 | * Create channel information array | 2085 | * Create channel information array |
2086 | */ | 2086 | */ |
2087 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | 2087 | info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); |
2088 | if (!info) | 2088 | if (!info) |
2089 | return -ENOMEM; | 2089 | return -ENOMEM; |
2090 | 2090 | ||
diff --git a/drivers/net/wireless/wl12xx/wl1271_scan.c b/drivers/net/wireless/wl12xx/wl1271_scan.c index fec43eed8c55..30dc1000f563 100644 --- a/drivers/net/wireless/wl12xx/wl1271_scan.c +++ b/drivers/net/wireless/wl12xx/wl1271_scan.c | |||
@@ -248,7 +248,7 @@ int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, | |||
248 | 248 | ||
249 | wl->scan.req = req; | 249 | wl->scan.req = req; |
250 | 250 | ||
251 | wl->scan.scanned_ch = kzalloc(req->n_channels * | 251 | wl->scan.scanned_ch = kcalloc(req->n_channels, |
252 | sizeof(*wl->scan.scanned_ch), | 252 | sizeof(*wl->scan.scanned_ch), |
253 | GFP_KERNEL); | 253 | GFP_KERNEL); |
254 | wl1271_scan_stm(wl); | 254 | wl1271_scan_stm(wl); |