aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKiran Divekar <kirandivekar@gmail.com>2009-08-28 08:17:59 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-28 14:41:01 -0400
commitad43f8bfb7b9a6a8b800cdad24c4a62180a5eb3d (patch)
tree8c3f03efdfe2e1abc0418ef485c831ba1dd6cdd4
parent04a6445f6f5e439ef775bd18cf3f485f84bbfb1b (diff)
libertas: add NULL check on return value of get_zeroed_page
Most of the places in debugfs.c are missing a NULL check on the return value of get_zeroed_page API call. Added required NULL check at appropriate places. Signed-off-by: Kiran Divekar <kirandivekar@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/libertas/debugfs.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 811ffc3ef414..893a55ca344a 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -45,6 +45,8 @@ static ssize_t lbs_dev_info(struct file *file, char __user *userbuf,
45 unsigned long addr = get_zeroed_page(GFP_KERNEL); 45 unsigned long addr = get_zeroed_page(GFP_KERNEL);
46 char *buf = (char *)addr; 46 char *buf = (char *)addr;
47 ssize_t res; 47 ssize_t res;
48 if (!buf)
49 return -ENOMEM;
48 50
49 pos += snprintf(buf+pos, len-pos, "state = %s\n", 51 pos += snprintf(buf+pos, len-pos, "state = %s\n",
50 szStates[priv->connect_status]); 52 szStates[priv->connect_status]);
@@ -68,6 +70,8 @@ static ssize_t lbs_getscantable(struct file *file, char __user *userbuf,
68 char *buf = (char *)addr; 70 char *buf = (char *)addr;
69 DECLARE_SSID_BUF(ssid); 71 DECLARE_SSID_BUF(ssid);
70 struct bss_descriptor * iter_bss; 72 struct bss_descriptor * iter_bss;
73 if (!buf)
74 return -ENOMEM;
71 75
72 pos += snprintf(buf+pos, len-pos, 76 pos += snprintf(buf+pos, len-pos,
73 "# | ch | rssi | bssid | cap | Qual | SSID \n"); 77 "# | ch | rssi | bssid | cap | Qual | SSID \n");
@@ -110,6 +114,8 @@ static ssize_t lbs_sleepparams_write(struct file *file,
110 int p1, p2, p3, p4, p5, p6; 114 int p1, p2, p3, p4, p5, p6;
111 unsigned long addr = get_zeroed_page(GFP_KERNEL); 115 unsigned long addr = get_zeroed_page(GFP_KERNEL);
112 char *buf = (char *)addr; 116 char *buf = (char *)addr;
117 if (!buf)
118 return -ENOMEM;
113 119
114 buf_size = min(count, len - 1); 120 buf_size = min(count, len - 1);
115 if (copy_from_user(buf, user_buf, buf_size)) { 121 if (copy_from_user(buf, user_buf, buf_size)) {
@@ -148,6 +154,8 @@ static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf,
148 struct sleep_params sp; 154 struct sleep_params sp;
149 unsigned long addr = get_zeroed_page(GFP_KERNEL); 155 unsigned long addr = get_zeroed_page(GFP_KERNEL);
150 char *buf = (char *)addr; 156 char *buf = (char *)addr;
157 if (!buf)
158 return -ENOMEM;
151 159
152 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp); 160 ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp);
153 if (ret) 161 if (ret)
@@ -433,6 +441,8 @@ static ssize_t lbs_rdmac_read(struct file *file, char __user *userbuf,
433 int ret; 441 int ret;
434 unsigned long addr = get_zeroed_page(GFP_KERNEL); 442 unsigned long addr = get_zeroed_page(GFP_KERNEL);
435 char *buf = (char *)addr; 443 char *buf = (char *)addr;
444 if (!buf)
445 return -ENOMEM;
436 446
437 offval.offset = priv->mac_offset; 447 offval.offset = priv->mac_offset;
438 offval.value = 0; 448 offval.value = 0;
@@ -457,6 +467,8 @@ static ssize_t lbs_rdmac_write(struct file *file,
457 ssize_t res, buf_size; 467 ssize_t res, buf_size;
458 unsigned long addr = get_zeroed_page(GFP_KERNEL); 468 unsigned long addr = get_zeroed_page(GFP_KERNEL);
459 char *buf = (char *)addr; 469 char *buf = (char *)addr;
470 if (!buf)
471 return -ENOMEM;
460 472
461 buf_size = min(count, len - 1); 473 buf_size = min(count, len - 1);
462 if (copy_from_user(buf, userbuf, buf_size)) { 474 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -481,6 +493,8 @@ static ssize_t lbs_wrmac_write(struct file *file,
481 struct lbs_offset_value offval; 493 struct lbs_offset_value offval;
482 unsigned long addr = get_zeroed_page(GFP_KERNEL); 494 unsigned long addr = get_zeroed_page(GFP_KERNEL);
483 char *buf = (char *)addr; 495 char *buf = (char *)addr;
496 if (!buf)
497 return -ENOMEM;
484 498
485 buf_size = min(count, len - 1); 499 buf_size = min(count, len - 1);
486 if (copy_from_user(buf, userbuf, buf_size)) { 500 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -515,6 +529,8 @@ static ssize_t lbs_rdbbp_read(struct file *file, char __user *userbuf,
515 int ret; 529 int ret;
516 unsigned long addr = get_zeroed_page(GFP_KERNEL); 530 unsigned long addr = get_zeroed_page(GFP_KERNEL);
517 char *buf = (char *)addr; 531 char *buf = (char *)addr;
532 if (!buf)
533 return -ENOMEM;
518 534
519 offval.offset = priv->bbp_offset; 535 offval.offset = priv->bbp_offset;
520 offval.value = 0; 536 offval.value = 0;
@@ -540,6 +556,8 @@ static ssize_t lbs_rdbbp_write(struct file *file,
540 ssize_t res, buf_size; 556 ssize_t res, buf_size;
541 unsigned long addr = get_zeroed_page(GFP_KERNEL); 557 unsigned long addr = get_zeroed_page(GFP_KERNEL);
542 char *buf = (char *)addr; 558 char *buf = (char *)addr;
559 if (!buf)
560 return -ENOMEM;
543 561
544 buf_size = min(count, len - 1); 562 buf_size = min(count, len - 1);
545 if (copy_from_user(buf, userbuf, buf_size)) { 563 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -564,6 +582,8 @@ static ssize_t lbs_wrbbp_write(struct file *file,
564 struct lbs_offset_value offval; 582 struct lbs_offset_value offval;
565 unsigned long addr = get_zeroed_page(GFP_KERNEL); 583 unsigned long addr = get_zeroed_page(GFP_KERNEL);
566 char *buf = (char *)addr; 584 char *buf = (char *)addr;
585 if (!buf)
586 return -ENOMEM;
567 587
568 buf_size = min(count, len - 1); 588 buf_size = min(count, len - 1);
569 if (copy_from_user(buf, userbuf, buf_size)) { 589 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -598,6 +618,8 @@ static ssize_t lbs_rdrf_read(struct file *file, char __user *userbuf,
598 int ret; 618 int ret;
599 unsigned long addr = get_zeroed_page(GFP_KERNEL); 619 unsigned long addr = get_zeroed_page(GFP_KERNEL);
600 char *buf = (char *)addr; 620 char *buf = (char *)addr;
621 if (!buf)
622 return -ENOMEM;
601 623
602 offval.offset = priv->rf_offset; 624 offval.offset = priv->rf_offset;
603 offval.value = 0; 625 offval.value = 0;
@@ -623,6 +645,8 @@ static ssize_t lbs_rdrf_write(struct file *file,
623 ssize_t res, buf_size; 645 ssize_t res, buf_size;
624 unsigned long addr = get_zeroed_page(GFP_KERNEL); 646 unsigned long addr = get_zeroed_page(GFP_KERNEL);
625 char *buf = (char *)addr; 647 char *buf = (char *)addr;
648 if (!buf)
649 return -ENOMEM;
626 650
627 buf_size = min(count, len - 1); 651 buf_size = min(count, len - 1);
628 if (copy_from_user(buf, userbuf, buf_size)) { 652 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -647,6 +671,8 @@ static ssize_t lbs_wrrf_write(struct file *file,
647 struct lbs_offset_value offval; 671 struct lbs_offset_value offval;
648 unsigned long addr = get_zeroed_page(GFP_KERNEL); 672 unsigned long addr = get_zeroed_page(GFP_KERNEL);
649 char *buf = (char *)addr; 673 char *buf = (char *)addr;
674 if (!buf)
675 return -ENOMEM;
650 676
651 buf_size = min(count, len - 1); 677 buf_size = min(count, len - 1);
652 if (copy_from_user(buf, userbuf, buf_size)) { 678 if (copy_from_user(buf, userbuf, buf_size)) {
@@ -853,6 +879,8 @@ static ssize_t lbs_debugfs_read(struct file *file, char __user *userbuf,
853 struct debug_data *d; 879 struct debug_data *d;
854 unsigned long addr = get_zeroed_page(GFP_KERNEL); 880 unsigned long addr = get_zeroed_page(GFP_KERNEL);
855 char *buf = (char *)addr; 881 char *buf = (char *)addr;
882 if (!buf)
883 return -ENOMEM;
856 884
857 p = buf; 885 p = buf;
858 886