diff mbox series

[1/5,v3] wifi: mwifiex: fix memory leak in mwifiex_histogram_read()

Message ID 20230802160726.85545-1-dmantipov@yandex.ru
State New
Headers show
Series [1/5,v3] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() | expand

Commit Message

Dmitry Antipov Aug. 2, 2023, 4:07 p.m. UTC
Always free the zeroed page on return from 'mwifiex_histogram_read()'.

Fixes: cbf6e05527a7 ("mwifiex: add rx histogram statistics support")

Acked-by: Brian Norris <briannorris@chromium.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v3: add Acked-by: and reorder series
---
 drivers/net/wireless/marvell/mwifiex/debugfs.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Kalle Valo Aug. 21, 2023, 3:56 p.m. UTC | #1
Dmitry Antipov <dmantipov@yandex.ru> wrote:

> Always free the zeroed page on return from 'mwifiex_histogram_read()'.
> 
> Fixes: cbf6e05527a7 ("mwifiex: add rx histogram statistics support")
> 
> Acked-by: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

5 patches applied to wireless-next.git, thanks.

9c8fd72a5c2a wifi: mwifiex: fix memory leak in mwifiex_histogram_read()
9b1cd8266f35 wifi: mwifiex: cleanup private data structures
968d02c61311 wifi: mwifiex: handle possible sscanf() errors
a6b3a0169ade wifi: mwifiex: handle possible mwifiex_write_reg() errors
359838758cea wifi: mwifiex: drop BUG_ON from TX paths
diff mbox series

Patch

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;
 }