On 09/27/2010 09:17 AM, Johannes Berg wrote:
On Mon, 2010-09-27 at 09:07 -0700, greearb@xxxxxxxxx wrote:
@@ -346,16 +332,36 @@ struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
if (unlikely(!wiphy_idx_valid(rdev->wiphy_idx))) {
wiphy_counter--;
+ goto too_many_devs;
+ }
I believe the other path can also reduce the counter again, since it's
another failure case? Not that I'm really worried about it though.
+ /* 64k wiphy devices is enough for anyone! */
+ for (i = 0; i< 0xFFFF; i++) {
Come to think of it, this could be "i<= wiphy_counter", since in N
devices, only N different names can be in use, so checking N+1 names
will be sufficient, right?
I think it doesn't matter so much either way. If we want to get really
paranoid about this, then we need to hash lookup of phy by index and name
and probably allow some reuse of phy indexes in case someone wants to reload
a module 4 billion times.
But, since current use is probably < 2 phys in most cases, and less than 500 in
all cases, I think we could just leave the code as is. I'd guess the only reason
to change this is if we ever get usable virtual phys (netdev had the same migration
when VLANs started being useful and suddenly it was OK to have several thousand
interfaces.)
That said, I'll redo the patch if you want these changes.
Thanks,
Ben
johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
Ben Greear <greearb@xxxxxxxxxxxxxxx>
Candela Technologies Inc http://www.candelatech.com
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html