* [PATCH] wifi: mwifiex: fix memory leak in mwifiex_histogram_read()
@ 2023-07-11 8:24 Dmitry Antipov
2023-07-13 0:58 ` Jakub Kicinski
0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Antipov @ 2023-07-11 8:24 UTC (permalink / raw)
To: Kalle Valo; +Cc: Brian Norris, linux-wireless, Dmitry Antipov
Always free the zeroed page on return from mwifiex_histogram_read().
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
drivers/net/wireless/marvell/mwifiex/debugfs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c
index 52b18f4a774b..0cdd6c50c1c0 100644
--- a/drivers/net/wireless/marvell/mwifiex/debugfs.c
+++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c
@@ -253,8 +253,11 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf,
if (!p)
return -ENOMEM;
- if (!priv || !priv->hist_data)
- return -EFAULT;
+ if (!priv || !priv->hist_data) {
+ ret = -EFAULT;
+ goto free_and_exit;
+ }
+
phist_data = priv->hist_data;
p += sprintf(p, "\n"
@@ -309,6 +312,8 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf,
ret = simple_read_from_buffer(ubuf, count, ppos, (char *)page,
(unsigned long)p - page);
+free_and_exit:
+ free_page(page);
return ret;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: mwifiex: fix memory leak in mwifiex_histogram_read()
2023-07-11 8:24 [PATCH] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Dmitry Antipov
@ 2023-07-13 0:58 ` Jakub Kicinski
2023-07-13 4:43 ` [PATCH] [v2] " Dmitry Antipov
0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2023-07-13 0:58 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: Kalle Valo, Brian Norris, linux-wireless
On Tue, 11 Jul 2023 11:24:53 +0300 Dmitry Antipov wrote:
> Always free the zeroed page on return from mwifiex_histogram_read().
Fixes: ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] [v2] wifi: mwifiex: fix memory leak in mwifiex_histogram_read()
2023-07-13 0:58 ` Jakub Kicinski
@ 2023-07-13 4:43 ` Dmitry Antipov
0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Antipov @ 2023-07-13 4:43 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Brian Norris, Kalle Valo, linux-wireless, Dmitry Antipov
Always free the zeroed page on return from mwifiex_histogram_read().
Fixes: cbf6e05527a76 ("mwifiex: add rx histogram statistics support")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: add Fixes: reference (Jakub Kicinski)
---
drivers/net/wireless/marvell/mwifiex/debugfs.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/marvell/mwifiex/debugfs.c b/drivers/net/wireless/marvell/mwifiex/debugfs.c
index 52b18f4a774b..0cdd6c50c1c0 100644
--- a/drivers/net/wireless/marvell/mwifiex/debugfs.c
+++ b/drivers/net/wireless/marvell/mwifiex/debugfs.c
@@ -253,8 +253,11 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf,
if (!p)
return -ENOMEM;
- if (!priv || !priv->hist_data)
- return -EFAULT;
+ if (!priv || !priv->hist_data) {
+ ret = -EFAULT;
+ goto free_and_exit;
+ }
+
phist_data = priv->hist_data;
p += sprintf(p, "\n"
@@ -309,6 +312,8 @@ mwifiex_histogram_read(struct file *file, char __user *ubuf,
ret = simple_read_from_buffer(ubuf, count, ppos, (char *)page,
(unsigned long)p - page);
+free_and_exit:
+ free_page(page);
return ret;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-07-13 4:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-11 8:24 [PATCH] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Dmitry Antipov
2023-07-13 0:58 ` Jakub Kicinski
2023-07-13 4:43 ` [PATCH] [v2] " Dmitry Antipov
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).