* [PATCH] ath9k: Fix write callback of 'debug' which configures debug mask
@ 2009-06-02 13:58 Vasanthakumar Thiagarajan
2009-06-02 13:58 ` [PATCH] ath9k: Remove modparam 'debug' Vasanthakumar Thiagarajan
0 siblings, 1 reply; 5+ messages in thread
From: Vasanthakumar Thiagarajan @ 2009-06-02 13:58 UTC (permalink / raw)
To: linville; +Cc: linux-wireless, Luis.Rodriguez, Jouni.Malinen, ath9k-devel
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>
---
drivers/net/wireless/ath/ath9k/debug.c | 22 ++++++++++++++--------
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 a42d631..6d20725 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,
{
struct ath_softc *sc = file->private_data;
char buf[32];
- unsigned int len = 0;
- len += snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask);
+ unsigned int len;
+
+ len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.debug_mask);
return simple_read_from_buffer(user_buf, count, ppos, buf, len);
}
@@ -60,12 +61,17 @@ static ssize_t write_file_debug(struct file *file, const char __user *user_buf,
struct ath_softc *sc = file->private_data;
unsigned long mask;
char buf[32];
- if (copy_from_user(buf, user_buf, (sizeof(buf) - 1) < count ?
- (sizeof(buf) - 1) : count))
- return 0;
- buf[sizeof(buf)-1] = 0;
- if (strict_strtoul(buf, 0, &mask) == 0)
- sc->debug.debug_mask = mask;
+ ssize_t len;
+
+ len = min(count, sizeof(buf) - 1);
+ if (copy_from_user(buf, user_buf, len))
+ return -EINVAL;
+
+ buf[len] = '\0';
+ if (strict_strtoul(buf, 0, &mask))
+ return -EINVAL;
+
+ sc->debug.debug_mask = mask;
return count;
}
--
1.5.5.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH] ath9k: Remove modparam 'debug'
2009-06-02 13:58 [PATCH] ath9k: Fix write callback of 'debug' which configures debug mask Vasanthakumar Thiagarajan
@ 2009-06-02 13:58 ` Vasanthakumar Thiagarajan
2009-06-02 16:43 ` Luis R. Rodriguez
2009-06-03 5:00 ` Vasanthakumar Thiagarajan
0 siblings, 2 replies; 5+ messages in thread
From: Vasanthakumar Thiagarajan @ 2009-06-02 13:58 UTC (permalink / raw)
To: linville; +Cc: linux-wireless, Luis.Rodriguez, Jouni.Malinen, ath9k-devel
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
---
drivers/net/wireless/ath/ath9k/Kconfig | 4 ++--
drivers/net/wireless/ath/ath9k/debug.c | 5 +----
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
index 0ed1ac3..a5ab53f 100644
--- a/drivers/net/wireless/ath/ath9k/Kconfig
+++ b/drivers/net/wireless/ath/ath9k/Kconfig
@@ -17,8 +17,8 @@ config ATH9K_DEBUG
depends on ATH9K
---help---
Say Y, if you need ath9k to display debug messages.
- Pass the debug mask as a module parameter:
+ Pass the debug mask through debugfs interface:
- modprobe ath9k debug=0x00002000
+ echo <debug mask> > /<debugfsroot>/ath9k/phyX/debug
Look in ath9k/core.h for possible debug masks
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 6d20725..a4c0c7a 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -18,9 +18,6 @@
#include "ath9k.h"
-static unsigned int ath9k_debug = DBG_DEFAULT;
-module_param_named(debug, ath9k_debug, uint, 0);
-
static struct dentry *ath9k_debugfs_root;
void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
@@ -489,7 +486,7 @@ static const struct file_operations fops_wiphy = {
int ath9k_init_debug(struct ath_softc *sc)
{
- sc->debug.debug_mask = ath9k_debug;
+ sc->debug.debug_mask = DBG_DEFAULT;
if (!ath9k_debugfs_root)
return -ENOENT;
--
1.5.5.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] ath9k: Remove modparam 'debug'
2009-06-02 13:58 ` [PATCH] ath9k: Remove modparam 'debug' Vasanthakumar Thiagarajan
@ 2009-06-02 16:43 ` Luis R. Rodriguez
2009-06-03 4:57 ` Vasanthakumar Thiagarajan
2009-06-03 5:00 ` Vasanthakumar Thiagarajan
1 sibling, 1 reply; 5+ messages in thread
From: Luis R. Rodriguez @ 2009-06-02 16:43 UTC (permalink / raw)
To: Vasanth Thiagarajan
Cc: linville@tuxdriver.com, linux-wireless@vger.kernel.org,
Luis Rodriguez, Jouni Malinen, ath9k-devel@lists.ath9k.org
On Tue, Jun 02, 2009 at 06:58:56AM -0700, Vasanth Thiagarajan wrote:
> - modprobe ath9k debug=0x00002000
> + echo <debug mask> > /<debugfsroot>/ath9k/phyX/debug
This means no debugging available during module init which does seem
useful to keep.
Luis
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ath9k: Remove modparam 'debug'
2009-06-02 16:43 ` Luis R. Rodriguez
@ 2009-06-03 4:57 ` Vasanthakumar Thiagarajan
0 siblings, 0 replies; 5+ messages in thread
From: Vasanthakumar Thiagarajan @ 2009-06-03 4:57 UTC (permalink / raw)
To: Luis Rodriguez
Cc: Vasanth Thiagarajan, linville@tuxdriver.com,
linux-wireless@vger.kernel.org, Jouni Malinen,
ath9k-devel@lists.ath9k.org
On Tue, Jun 02, 2009 at 10:13:38PM +0530, Luis Rodriguez wrote:
> On Tue, Jun 02, 2009 at 06:58:56AM -0700, Vasanth Thiagarajan wrote:
> > - modprobe ath9k debug=0x00002000
> > + echo <debug mask> > /<debugfsroot>/ath9k/phyX/debug
>
> This means no debugging available during module init which does seem
> useful to keep.
Thats true,let's keep it, thanks.
Vasanth
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ath9k: Remove modparam 'debug'
2009-06-02 13:58 ` [PATCH] ath9k: Remove modparam 'debug' Vasanthakumar Thiagarajan
2009-06-02 16:43 ` Luis R. Rodriguez
@ 2009-06-03 5:00 ` Vasanthakumar Thiagarajan
1 sibling, 0 replies; 5+ messages in thread
From: Vasanthakumar Thiagarajan @ 2009-06-03 5:00 UTC (permalink / raw)
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org, Luis Rodriguez, Jouni Malinen,
ath9k-devel@lists.ath9k.org
On Tue, Jun 02, 2009 at 07:28:56PM +0530, Vasanth Thiagarajan wrote:
John,
> Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
> ---
> drivers/net/wireless/ath/ath9k/Kconfig | 4 ++--
> drivers/net/wireless/ath/ath9k/debug.c | 5 +----
> 2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig
> index 0ed1ac3..a5ab53f 100644
> --- a/drivers/net/wireless/ath/ath9k/Kconfig
> +++ b/drivers/net/wireless/ath/ath9k/Kconfig
> @@ -17,8 +17,8 @@ config ATH9K_DEBUG
> depends on ATH9K
> ---help---
> Say Y, if you need ath9k to display debug messages.
> - Pass the debug mask as a module parameter:
> + Pass the debug mask through debugfs interface:
>
> - modprobe ath9k debug=0x00002000
> + echo <debug mask> > /<debugfsroot>/ath9k/phyX/debug
>
> Look in ath9k/core.h for possible debug masks
> diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
> index 6d20725..a4c0c7a 100644
> --- a/drivers/net/wireless/ath/ath9k/debug.c
> +++ b/drivers/net/wireless/ath/ath9k/debug.c
> @@ -18,9 +18,6 @@
>
> #include "ath9k.h"
>
> -static unsigned int ath9k_debug = DBG_DEFAULT;
> -module_param_named(debug, ath9k_debug, uint, 0);
> -
> static struct dentry *ath9k_debugfs_root;
>
> void DPRINTF(struct ath_softc *sc, int dbg_mask, const char *fmt, ...)
> @@ -489,7 +486,7 @@ static const struct file_operations fops_wiphy = {
>
> int ath9k_init_debug(struct ath_softc *sc)
> {
> - sc->debug.debug_mask = ath9k_debug;
> + sc->debug.debug_mask = DBG_DEFAULT;
>
> if (!ath9k_debugfs_root)
> return -ENOENT;
> --
> 1.5.5.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Please ignore this patch as we will miss debug information during
device attach time if we remove the option to pass debug mask as
modparam. thanks.
Vasanth
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-03 5:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 13:58 [PATCH] ath9k: Fix write callback of 'debug' which configures debug mask Vasanthakumar Thiagarajan
2009-06-02 13:58 ` [PATCH] ath9k: Remove modparam 'debug' Vasanthakumar Thiagarajan
2009-06-02 16:43 ` Luis R. Rodriguez
2009-06-03 4:57 ` Vasanthakumar Thiagarajan
2009-06-03 5:00 ` Vasanthakumar Thiagarajan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).