linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath6kl: Fix endpoint_stats debugfs buffer length calculation
@ 2011-10-11 19:08 Jouni Malinen
  2011-10-13 10:29 ` Kalle Valo
  0 siblings, 1 reply; 2+ messages in thread
From: Jouni Malinen @ 2011-10-11 19:08 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless, Joe Perches

The previous version did not really make much sense and the theoretical
maximum length would be a bit longer. Calculate the length more
accurately. In addition, there is no need to clear the buffer, so use
kmalloc instead of kzalloc. For bonus points, add the forgotten
cred_rpt_from_other value to the file.

Reported-by: Joe Perches <joe@perches.com>
Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/debug.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index 7b1c9ae..dd37785 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -624,8 +624,9 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file,
 	unsigned int buf_len, len = 0;
 	ssize_t ret_cnt;
 
-	buf_len = 1000 + ENDPOINT_MAX * 100;
-	buf = kzalloc(buf_len, GFP_KERNEL);
+	buf_len = sizeof(struct htc_endpoint_stats) / sizeof(u32) *
+		(25 + ENDPOINT_MAX * 11);
+	buf = kmalloc(buf_len, GFP_KERNEL);
 	if (!buf)
 		return -ENOMEM;
 
@@ -640,6 +641,7 @@ static ssize_t ath6kl_endpoint_stats_read(struct file *file,
 	EPSTAT(tx_dropped);
 	EPSTAT(tx_cred_rpt);
 	EPSTAT(cred_rpt_from_rx);
+	EPSTAT(cred_rpt_from_other);
 	EPSTAT(cred_rpt_ep0);
 	EPSTAT(cred_from_rx);
 	EPSTAT(cred_from_other);
-- 
1.7.4.1


-- 
Jouni Malinen                                            PGP id EFC895FA

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ath6kl: Fix endpoint_stats debugfs buffer length calculation
  2011-10-11 19:08 [PATCH] ath6kl: Fix endpoint_stats debugfs buffer length calculation Jouni Malinen
@ 2011-10-13 10:29 ` Kalle Valo
  0 siblings, 0 replies; 2+ messages in thread
From: Kalle Valo @ 2011-10-13 10:29 UTC (permalink / raw)
  To: Jouni Malinen; +Cc: linux-wireless, Joe Perches

On 10/11/2011 10:08 PM, Jouni Malinen wrote:
> The previous version did not really make much sense and the theoretical
> maximum length would be a bit longer. Calculate the length more
> accurately. In addition, there is no need to clear the buffer, so use
> kmalloc instead of kzalloc. For bonus points, add the forgotten
> cred_rpt_from_other value to the file.

Thanks, applied.

Kalle

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-13 10:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-11 19:08 [PATCH] ath6kl: Fix endpoint_stats debugfs buffer length calculation Jouni Malinen
2011-10-13 10:29 ` Kalle Valo

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).