Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 102953
b: refs/heads/master
c: 90d0734
h: refs/heads/master
i:
  102951: 16a3538
v: v3
  • Loading branch information
Jussi Kivilinna authored and John W. Linville committed Jun 14, 2008
1 parent db812f3 commit 9a6a307
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 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: bb8649d42989eddf9c7d128114c1adcffe9eef54
refs/heads/master: 90d07349f8d754b89de8c61bdef9f95688900f30
47 changes: 33 additions & 14 deletions trunk/drivers/net/wireless/rndis_wlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ enum wpa_key_mgmt { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE,
#define WORK_LINK_DOWN (1<<1)
#define WORK_SET_MULTICAST_LIST (1<<2)

#define COMMAND_BUFFER_SIZE (CONTROL_BUFFER_SIZE + sizeof(struct rndis_set))

/* RNDIS device private data */
struct rndis_wext_private {
char name[32];
Expand Down Expand Up @@ -362,6 +364,8 @@ struct rndis_wext_private {
u8 *wpa_ie;
int wpa_cipher_pair;
int wpa_cipher_group;

u8 command_buffer[COMMAND_BUFFER_SIZE];
};


Expand Down Expand Up @@ -428,26 +432,34 @@ static int rndis_query_oid(struct usbnet *dev, __le32 oid, void *data, int *len)
buflen = *len + sizeof(*u.get);
if (buflen < CONTROL_BUFFER_SIZE)
buflen = CONTROL_BUFFER_SIZE;
u.buf = kmalloc(buflen, GFP_KERNEL);
if (!u.buf)
return -ENOMEM;

if (buflen > COMMAND_BUFFER_SIZE) {
u.buf = kmalloc(buflen, GFP_KERNEL);
if (!u.buf)
return -ENOMEM;
} else {
u.buf = priv->command_buffer;
}

mutex_lock(&priv->command_lock);

memset(u.get, 0, sizeof *u.get);
u.get->msg_type = RNDIS_MSG_QUERY;
u.get->msg_len = ccpu2(sizeof *u.get);
u.get->oid = oid;

mutex_lock(&priv->command_lock);
ret = rndis_command(dev, u.header);
mutex_unlock(&priv->command_lock);

if (ret == 0) {
ret = le32_to_cpu(u.get_c->len);
*len = (*len > ret) ? ret : *len;
memcpy(data, u.buf + le32_to_cpu(u.get_c->offset) + 8, *len);
ret = rndis_error_status(u.get_c->status);
}

kfree(u.buf);
mutex_unlock(&priv->command_lock);

if (u.buf != priv->command_buffer)
kfree(u.buf);
return ret;
}

Expand All @@ -466,9 +478,16 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len)
buflen = len + sizeof(*u.set);
if (buflen < CONTROL_BUFFER_SIZE)
buflen = CONTROL_BUFFER_SIZE;
u.buf = kmalloc(buflen, GFP_KERNEL);
if (!u.buf)
return -ENOMEM;

if (buflen > COMMAND_BUFFER_SIZE) {
u.buf = kmalloc(buflen, GFP_KERNEL);
if (!u.buf)
return -ENOMEM;
} else {
u.buf = priv->command_buffer;
}

mutex_lock(&priv->command_lock);

memset(u.set, 0, sizeof *u.set);
u.set->msg_type = RNDIS_MSG_SET;
Expand All @@ -479,14 +498,14 @@ static int rndis_set_oid(struct usbnet *dev, __le32 oid, void *data, int len)
u.set->handle = ccpu2(0);
memcpy(u.buf + sizeof(*u.set), data, len);

mutex_lock(&priv->command_lock);
ret = rndis_command(dev, u.header);
mutex_unlock(&priv->command_lock);

if (ret == 0)
ret = rndis_error_status(u.set_c->status);

kfree(u.buf);
mutex_unlock(&priv->command_lock);

if (u.buf != priv->command_buffer)
kfree(u.buf);
return ret;
}

Expand Down

0 comments on commit 9a6a307

Please sign in to comment.