All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath10k: fix debug cal data file
@ 2016-09-20  3:26 ` Nikolay Martynov
  0 siblings, 0 replies; 6+ messages in thread
From: Nikolay Martynov @ 2016-09-20  3:26 UTC (permalink / raw)
  To: kvalo; +Cc: Nikolay Martynov, ath10k, linux-wireless

It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
---
 drivers/net/wireless/ath/ath10k/debug.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 8f0fd41..7e82947 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -109,6 +109,11 @@ struct ath10k_dump_file_data {
 	u8 data[0];
 } __packed;
 
+struct ath10k_debug_cal_data {
+	u32 len;
+	u8 buf[0];
+};
+
 void ath10k_info(struct ath10k *ar, const char *fmt, ...)
 {
 	struct va_format vaf = {
@@ -1453,7 +1458,8 @@ static const struct file_operations fops_fw_dbglog = {
 static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 {
 	struct ath10k *ar = inode->i_private;
-	void *buf;
+	struct ath10k_debug_cal_data *data;
+	u32 len;
 	u32 hi_addr;
 	__le32 addr;
 	int ret;
@@ -1466,12 +1472,15 @@ static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 		goto err;
 	}
 
-	buf = vmalloc(ar->hw_params.cal_data_len);
-	if (!buf) {
+	len = ar->hw_params.cal_data_len;
+	data = vmalloc(sizeof(struct ath10k_debug_cal_data) + len);
+	if (!data) {
 		ret = -ENOMEM;
 		goto err;
 	}
 
+	data->len = len;
+
 	hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
 
 	ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr));
@@ -1480,21 +1489,20 @@ static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 		goto err_vfree;
 	}
 
-	ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), buf,
-				   ar->hw_params.cal_data_len);
+	ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), data->buf, len);
 	if (ret) {
 		ath10k_warn(ar, "failed to read calibration data: %d\n", ret);
 		goto err_vfree;
 	}
 
-	file->private_data = buf;
+	file->private_data = data;
 
 	mutex_unlock(&ar->conf_mutex);
 
 	return 0;
 
 err_vfree:
-	vfree(buf);
+	vfree(data);
 
 err:
 	mutex_unlock(&ar->conf_mutex);
@@ -1506,11 +1514,10 @@ static ssize_t ath10k_debug_cal_data_read(struct file *file,
 					  char __user *user_buf,
 					  size_t count, loff_t *ppos)
 {
-	struct ath10k *ar = file->private_data;
-	void *buf = file->private_data;
+	struct ath10k_debug_cal_data *data = file->private_data;
 
 	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, ar->hw_params.cal_data_len);
+				       data->buf, data->len);
 }
 
 static int ath10k_debug_cal_data_release(struct inode *inode,
-- 
2.7.4

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

* [PATCH] ath10k: fix debug cal data file
@ 2016-09-20  3:26 ` Nikolay Martynov
  0 siblings, 0 replies; 6+ messages in thread
From: Nikolay Martynov @ 2016-09-20  3:26 UTC (permalink / raw)
  To: kvalo; +Cc: Nikolay Martynov, linux-wireless, ath10k

It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
---
 drivers/net/wireless/ath/ath10k/debug.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/debug.c b/drivers/net/wireless/ath/ath10k/debug.c
index 8f0fd41..7e82947 100644
--- a/drivers/net/wireless/ath/ath10k/debug.c
+++ b/drivers/net/wireless/ath/ath10k/debug.c
@@ -109,6 +109,11 @@ struct ath10k_dump_file_data {
 	u8 data[0];
 } __packed;
 
+struct ath10k_debug_cal_data {
+	u32 len;
+	u8 buf[0];
+};
+
 void ath10k_info(struct ath10k *ar, const char *fmt, ...)
 {
 	struct va_format vaf = {
@@ -1453,7 +1458,8 @@ static const struct file_operations fops_fw_dbglog = {
 static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 {
 	struct ath10k *ar = inode->i_private;
-	void *buf;
+	struct ath10k_debug_cal_data *data;
+	u32 len;
 	u32 hi_addr;
 	__le32 addr;
 	int ret;
@@ -1466,12 +1472,15 @@ static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 		goto err;
 	}
 
-	buf = vmalloc(ar->hw_params.cal_data_len);
-	if (!buf) {
+	len = ar->hw_params.cal_data_len;
+	data = vmalloc(sizeof(struct ath10k_debug_cal_data) + len);
+	if (!data) {
 		ret = -ENOMEM;
 		goto err;
 	}
 
+	data->len = len;
+
 	hi_addr = host_interest_item_address(HI_ITEM(hi_board_data));
 
 	ret = ath10k_hif_diag_read(ar, hi_addr, &addr, sizeof(addr));
@@ -1480,21 +1489,20 @@ static int ath10k_debug_cal_data_open(struct inode *inode, struct file *file)
 		goto err_vfree;
 	}
 
-	ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), buf,
-				   ar->hw_params.cal_data_len);
+	ret = ath10k_hif_diag_read(ar, le32_to_cpu(addr), data->buf, len);
 	if (ret) {
 		ath10k_warn(ar, "failed to read calibration data: %d\n", ret);
 		goto err_vfree;
 	}
 
-	file->private_data = buf;
+	file->private_data = data;
 
 	mutex_unlock(&ar->conf_mutex);
 
 	return 0;
 
 err_vfree:
-	vfree(buf);
+	vfree(data);
 
 err:
 	mutex_unlock(&ar->conf_mutex);
@@ -1506,11 +1514,10 @@ static ssize_t ath10k_debug_cal_data_read(struct file *file,
 					  char __user *user_buf,
 					  size_t count, loff_t *ppos)
 {
-	struct ath10k *ar = file->private_data;
-	void *buf = file->private_data;
+	struct ath10k_debug_cal_data *data = file->private_data;
 
 	return simple_read_from_buffer(user_buf, count, ppos,
-				       buf, ar->hw_params.cal_data_len);
+				       data->buf, data->len);
 }
 
 static int ath10k_debug_cal_data_release(struct inode *inode,
-- 
2.7.4


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: [PATCH] ath10k: fix debug cal data file
  2016-09-20  3:26 ` Nikolay Martynov
@ 2016-09-28 13:26   ` Valo, Kalle
  -1 siblings, 0 replies; 6+ messages in thread
From: Valo, Kalle @ 2016-09-28 13:26 UTC (permalink / raw)
  To: Nikolay Martynov; +Cc: linux-wireless, ath10k

Nikolay Martynov <mar.kolya@gmail.com> writes:

> It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4
>
> Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>

Good catch, I'll queue this to 4.9.

There was one checkpatch warning I fixed:

drivers/net/wireless/ath/ath10k/debug.c:1477: Prefer vmalloc(sizeof(*data).=
..) over vmalloc(sizeof(struct ath10k_debug_cal_data)...)

The commit log is quite short so added more information about the bug.
The full patch is in the pending branch.

Author: Nikolay Martynov <mar.kolya@gmail.com>
Date:   Wed Sep 28 15:11:52 2016 +0300

    ath10k: fix debug cal data file
   =20
    Commit 0b8e3c4ca29f ("ath10k: move cal data len to hw_params") broke re=
trieving
    the calibration data from cal_data debugfs file. The length of file was=
 always
    zero. The reason is:
   =20
    static ssize_t ath10k_debug_cal_data_read(struct file *file,
                                          char __user *user_buf,
                                          size_t count, loff_t *ppos)
    {
        struct ath10k *ar =3D file->private_data;
        void *buf =3D file->private_data;
   =20
   =20
    This is obviously bogus, private_data cannot contain both struct ath10k=
 and the
    buffer. Fix it by introducing a new temporary structure for storing bot=
h the
    length of the buffer and the actual buffer, then struct ath10k is not n=
eeded
    anymore.
   =20
    Fixes: 0b8e3c4ca29f ("ath10k: move cal data len to hw_params")
    Cc: stable@vger.kernel.org # 4.7+
    Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
    [kvalo@qca.qualcomm.com: improve commit log, fix a checkpatch warning]
    Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

--=20
Kalle Valo=

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

* Re: [PATCH] ath10k: fix debug cal data file
@ 2016-09-28 13:26   ` Valo, Kalle
  0 siblings, 0 replies; 6+ messages in thread
From: Valo, Kalle @ 2016-09-28 13:26 UTC (permalink / raw)
  To: Nikolay Martynov; +Cc: linux-wireless, ath10k

Nikolay Martynov <mar.kolya@gmail.com> writes:

> It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4
>
> Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>

Good catch, I'll queue this to 4.9.

There was one checkpatch warning I fixed:

drivers/net/wireless/ath/ath10k/debug.c:1477: Prefer vmalloc(sizeof(*data)...) over vmalloc(sizeof(struct ath10k_debug_cal_data)...)

The commit log is quite short so added more information about the bug.
The full patch is in the pending branch.

Author: Nikolay Martynov <mar.kolya@gmail.com>
Date:   Wed Sep 28 15:11:52 2016 +0300

    ath10k: fix debug cal data file
    
    Commit 0b8e3c4ca29f ("ath10k: move cal data len to hw_params") broke retrieving
    the calibration data from cal_data debugfs file. The length of file was always
    zero. The reason is:
    
    static ssize_t ath10k_debug_cal_data_read(struct file *file,
                                          char __user *user_buf,
                                          size_t count, loff_t *ppos)
    {
        struct ath10k *ar = file->private_data;
        void *buf = file->private_data;
    
    
    This is obviously bogus, private_data cannot contain both struct ath10k and the
    buffer. Fix it by introducing a new temporary structure for storing both the
    length of the buffer and the actual buffer, then struct ath10k is not needed
    anymore.
    
    Fixes: 0b8e3c4ca29f ("ath10k: move cal data len to hw_params")
    Cc: stable@vger.kernel.org # 4.7+
    Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
    [kvalo@qca.qualcomm.com: improve commit log, fix a checkpatch warning]
    Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>

-- 
Kalle Valo
_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

* Re: ath10k: fix debug cal data file
  2016-09-20  3:26 ` Nikolay Martynov
@ 2016-10-13 13:42   ` Kalle Valo
  -1 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2016-10-13 13:42 UTC (permalink / raw)
  To: Nikolay Martynov; +Cc: Nikolay Martynov, linux-wireless, ath10k

Nikolay Martynov <mar.kolya@gmail.com> wrote:
> It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4
> 
> Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>

Actually Marty's patch fixed this in a better way so I actually took that
instead:

f67b107d4ced ath10k: cache calibration data when the core is stopped

-- 
https://patchwork.kernel.org/patch/9340953/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

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

* Re: ath10k: fix debug cal data file
@ 2016-10-13 13:42   ` Kalle Valo
  0 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2016-10-13 13:42 UTC (permalink / raw)
  To: Nikolay Martynov; +Cc: linux-wireless, ath10k

Nikolay Martynov <mar.kolya@gmail.com> wrote:
> It got broken by 0b8e3c4ca29fe2c0efd3d41a76e34a657b9f17a4
> 
> Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>

Actually Marty's patch fixed this in a better way so I actually took that
instead:

f67b107d4ced ath10k: cache calibration data when the core is stopped

-- 
https://patchwork.kernel.org/patch/9340953/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


_______________________________________________
ath10k mailing list
ath10k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath10k

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

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

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20  3:26 [PATCH] ath10k: fix debug cal data file Nikolay Martynov
2016-09-20  3:26 ` Nikolay Martynov
2016-09-28 13:26 ` Valo, Kalle
2016-09-28 13:26   ` Valo, Kalle
2016-10-13 13:42 ` Kalle Valo
2016-10-13 13:42   ` Kalle Valo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.