Commit 99c893f3 authored by David Woodhouse's avatar David Woodhouse Committed by David S. Miller

libertas: Fix up error handling in lbs_setuserscan()

Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent c12bdc45
...@@ -293,19 +293,24 @@ static ssize_t lbs_setuserscan(struct file *file, ...@@ -293,19 +293,24 @@ static ssize_t lbs_setuserscan(struct file *file,
struct lbs_ioctl_user_scan_cfg *scan_cfg; struct lbs_ioctl_user_scan_cfg *scan_cfg;
union iwreq_data wrqu; union iwreq_data wrqu;
int dur; int dur;
unsigned long addr = get_zeroed_page(GFP_KERNEL); char *buf = (char *)get_zeroed_page(GFP_KERNEL);
char *buf = (char *)addr;
scan_cfg = kzalloc(sizeof(struct lbs_ioctl_user_scan_cfg), GFP_KERNEL); if (!buf)
if (!scan_cfg)
return -ENOMEM; return -ENOMEM;
buf_size = min(count, len - 1); buf_size = min(count, len - 1);
if (copy_from_user(buf, userbuf, buf_size)) { if (copy_from_user(buf, userbuf, buf_size)) {
res = -EFAULT; res = -EFAULT;
goto out_unlock; goto out_buf;
} }
scan_cfg = kzalloc(sizeof(struct lbs_ioctl_user_scan_cfg), GFP_KERNEL);
if (!scan_cfg) {
res = -ENOMEM;
goto out_buf;
}
res = count;
scan_cfg->bsstype = LBS_SCAN_BSS_TYPE_ANY; scan_cfg->bsstype = LBS_SCAN_BSS_TYPE_ANY;
dur = lbs_parse_dur(buf, count, scan_cfg); dur = lbs_parse_dur(buf, count, scan_cfg);
...@@ -317,15 +322,19 @@ static ssize_t lbs_setuserscan(struct file *file, ...@@ -317,15 +322,19 @@ static ssize_t lbs_setuserscan(struct file *file,
lbs_scan_networks(priv, scan_cfg, 1); lbs_scan_networks(priv, scan_cfg, 1);
wait_event_interruptible(priv->adapter->cmd_pending, wait_event_interruptible(priv->adapter->cmd_pending,
!priv->adapter->nr_cmd_pending); priv->adapter->surpriseremoved || !priv->adapter->nr_cmd_pending);
if (priv->adapter->surpriseremoved)
goto out_scan_cfg;
memset(&wrqu, 0x00, sizeof(union iwreq_data)); memset(&wrqu, 0x00, sizeof(union iwreq_data));
wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL);
out_unlock: out_scan_cfg:
free_page(addr);
kfree(scan_cfg); kfree(scan_cfg);
return count; out_buf:
free_page((unsigned long)buf);
return res;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment