Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 214975
b: refs/heads/master
c: 5a254ff
h: refs/heads/master
i:
  214973: bcf98d0
  214971: bcda960
  214967: c3a6435
  214959: e0f1420
  214943: b1b37a8
  214911: 7c3e53c
v: v3
  • Loading branch information
Ben Greear authored and John W. Linville committed Oct 5, 2010
1 parent bf1c149 commit 57b7f70
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b1a9338d5eaa9c38c326e20ce339247f4d585b62
refs/heads/master: 5a254ffe3ffdfa84fe076009bd8e88da412180d2
54 changes: 30 additions & 24 deletions trunk/net/wireless/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,34 +178,18 @@ int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
char *newname)
{
struct cfg80211_registered_device *rdev2;
int wiphy_idx, taken = -1, result, digits;
int result;

assert_cfg80211_lock();

/* prohibit calling the thing phy%d when %d is not its number */
sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
/* count number of places needed to print wiphy_idx */
digits = 1;
while (wiphy_idx /= 10)
digits++;
/*
* deny the name if it is phy<idx> where <idx> is printed
* without leading zeroes. taken == strlen(newname) here
*/
if (taken == strlen(PHY_NAME) + digits)
return -EINVAL;
}


/* Ignore nop renames */
if (strcmp(newname, dev_name(&rdev->wiphy.dev)) == 0)
return 0;

/* Ensure another device does not already have this name. */
list_for_each_entry(rdev2, &cfg80211_rdev_list, list)
if (strcmp(newname, dev_name(&rdev2->wiphy.dev)) == 0)
return -EINVAL;
return -EEXIST;

result = device_rename(&rdev->wiphy.dev, newname);
if (result)
Expand Down Expand Up @@ -320,9 +304,11 @@ static void cfg80211_event_work(struct work_struct *work)
struct wiphy *wiphy_new(const struct cfg80211_ops *ops, int sizeof_priv)
{
static int wiphy_counter;

struct cfg80211_registered_device *rdev;
int i;
struct cfg80211_registered_device *rdev, *rdev2;
int alloc_size;
char nname[IFNAMSIZ + 1];
bool found = false;

WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
Expand All @@ -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;
}

/* 64k wiphy devices is enough for anyone! */
for (i = 0; i < 0xFFFF; i++) {
found = false;
snprintf(nname, sizeof(nname)-1, PHY_NAME "%d", i);
nname[sizeof(nname)-1] = 0;
list_for_each_entry(rdev2, &cfg80211_rdev_list, list)
if (strcmp(nname, dev_name(&rdev2->wiphy.dev)) == 0) {
found = true;
break;
}

if (!found)
break;
}

if (unlikely(found)) {
too_many_devs:
mutex_unlock(&cfg80211_mutex);
/* ugh, wrapped! */
/* ugh, too many devices already! */
kfree(rdev);
return NULL;
}

mutex_unlock(&cfg80211_mutex);

/* give it a proper name */
dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
dev_set_name(&rdev->wiphy.dev, "%s", nname);

mutex_unlock(&cfg80211_mutex);

mutex_init(&rdev->mtx);
mutex_init(&rdev->devlist_mtx);
Expand Down

0 comments on commit 57b7f70

Please sign in to comment.