]> git.karo-electronics.de Git - linux-beck.git/commitdiff
regulatory: don't allocate too much memory
authorJohannes Berg <johannes.berg@intel.com>
Tue, 4 Dec 2012 11:49:16 +0000 (12:49 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 3 Jan 2013 12:01:19 +0000 (13:01 +0100)
There's no need to allocate one reg rule more
than will be used, reduce the allocations. The
allocation in nl80211 already doesn't allocate
too much space.

Acked-by: Luis R. Rodriguez <mcgrof@do-not-panic.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/reg.c

index 40646e823d5d743005d2ce2f763239512cd322de..62bf212e5648d76d88969a39b6dfda9edf8c175a 100644 (file)
@@ -318,8 +318,9 @@ static int reg_copy_regd(const struct ieee80211_regdomain **dst_regd,
        int size_of_regd = 0;
        unsigned int i;
 
-       size_of_regd = sizeof(struct ieee80211_regdomain) +
-         ((src_regd->n_reg_rules + 1) * sizeof(struct ieee80211_reg_rule));
+       size_of_regd =
+               sizeof(struct ieee80211_regdomain) +
+               src_regd->n_reg_rules * sizeof(struct ieee80211_reg_rule);
 
        regd = kzalloc(size_of_regd, GFP_KERNEL);
        if (!regd)
@@ -641,7 +642,7 @@ static struct ieee80211_regdomain *regdom_intersect(
                return NULL;
 
        size_of_regd = sizeof(struct ieee80211_regdomain) +
-               ((num_rules + 1) * sizeof(struct ieee80211_reg_rule));
+                      num_rules * sizeof(struct ieee80211_reg_rule);
 
        rd = kzalloc(size_of_regd, GFP_KERNEL);
        if (!rd)