]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
wifi: mwifiex: fix memory leak in mwifiex_histogram_read()
authorDmitry Antipov <dmantipov@yandex.ru>
Wed, 2 Aug 2023 16:07:15 +0000 (19:07 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Sep 2023 08:46:55 +0000 (10:46 +0200)
[ Upstream commit 9c8fd72a5c2a031cbc680a2990107ecd958ffcdb ]

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>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20230802160726.85545-1-dmantipov@yandex.ru
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/marvell/mwifiex/debugfs.c

index 49ca84ef1a992ab21c7b5e0eb3901e4c888963f9..b843be87112c02e5e637e09cb4358bf0211930fc 100644 (file)
@@ -288,8 +288,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"
@@ -344,6 +347,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;
 }