From patchwork Thu Jul 13 04:43:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 13311293 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B85DAEB64DD for ; Thu, 13 Jul 2023 04:45:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233446AbjGMEo7 (ORCPT ); Thu, 13 Jul 2023 00:44:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233032AbjGMEo6 (ORCPT ); Thu, 13 Jul 2023 00:44:58 -0400 Received: from forward102a.mail.yandex.net (forward102a.mail.yandex.net [178.154.239.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DECACF for ; Wed, 12 Jul 2023 21:44:55 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:170e:0:640:d60c:0]) by forward102a.mail.yandex.net (Yandex) with ESMTP id 9308441C62; Thu, 13 Jul 2023 07:44:53 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id qiSVn37DXCg0-XhxUOqWN; Thu, 13 Jul 2023 07:44:53 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1689223493; bh=cMdW4WRtGi9MWXlD0+g6bIkYHAToqAiodESle5tVj5E=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=wRnC6JG19PDgs5RzSjv4FQQzM3D7oNE6tBmkgiXcVUkoF3ViQeDX48GfhncRWtNTg f4GUYVYZnnGa5iSCZ91aWOM2sbd+SvVsAjXJ1E1Nys5cu1q08UJtFBic7vLHGioik+ DqE6V7tnQRC5+gTxAUfSmAIjVd5egw3xrxBn3ALg= Authentication-Results: mail-nwsmtp-smtp-production-main-64.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Jakub Kicinski Cc: Brian Norris , Kalle Valo , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] [v2] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Date: Thu, 13 Jul 2023 07:43:41 +0300 Message-ID: <20230713044434.12494-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230712175819.1f8a7c24@kernel.org> References: <20230712175819.1f8a7c24@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Always free the zeroed page on return from mwifiex_histogram_read(). Fixes: cbf6e05527a76 ("mwifiex: add rx histogram statistics support") Signed-off-by: Dmitry Antipov --- 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; }