aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath
diff options
context:
space:
mode:
authorVasanthakumar Thiagarajan <vasanth@atheros.com>2009-06-02 09:58:55 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-06-03 14:06:15 -0400
commit581f725ccd7e697074aa057fa86bf99b54052c95 (patch)
tree38da545a4f3b0af558414a875018579e3dc98832 /drivers/net/wireless/ath
parent76963bb602ba91927130a0140d5757a5969e08ac (diff)
ath9k: Fix write callback of 'debug' which configures debug mask
Handle error condition on copy_from_user() properly and make sure a NUL terminated char[] is sent to strict_strtoul() for proper conversion. Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath')
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index a42d631e7456..6d20725d6451 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -49,8 +49,9 @@ static ssize_t read_file_debug(struct file *file, char __user *user_buf,
49{ 49{
50 struct ath_softc *sc = file->private_data; 50 struct ath_softc *sc = file->private_data;
51 char buf[32]; 51 char buf[32];
52 unsigned int len = 0; 52 unsigned int len;
53 len += snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask); 53
54 len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask);
54 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 55 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
55} 56}
56 57
@@ -60,12 +61,17 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
60 struct ath_softc *sc = file->private_data; 61 struct ath_softc *sc = file->private_data;
61 unsigned long mask; 62 unsigned long mask;
62 char buf[32]; 63 char buf[32];
63 if (copy_from_user(buf, user_buf, (sizeof(buf) - 1) < count ? 64 ssize_t len;
64 (sizeof(buf) - 1) : count)) 65
65 return 0; 66 len = min(count, sizeof(buf) - 1);
66 buf[sizeof(buf)-1] = 0; 67 if (copy_from_user(buf, user_buf, len))
67 if (strict_strtoul(buf, 0, &mask) == 0) 68 return -EINVAL;
68 sc->debug.debug_mask = mask; 69
70 buf[len] = '\0';
71 if (strict_strtoul(buf, 0, &mask))
72 return -EINVAL;
73
74 sc->debug.debug_mask = mask;
69 return count; 75 return count;
70} 76}
71 77