From patchwork Tue Jul 11 08:24:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Antipov X-Patchwork-Id: 701848 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 BBEECC0015E for ; Tue, 11 Jul 2023 08:25:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231215AbjGKIZR (ORCPT ); Tue, 11 Jul 2023 04:25:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbjGKIZQ (ORCPT ); Tue, 11 Jul 2023 04:25:16 -0400 Received: from forward100b.mail.yandex.net (forward100b.mail.yandex.net [178.154.239.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E93B0E6F for ; Tue, 11 Jul 2023 01:25:10 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:2891:0:640:3c15:0]) by forward100b.mail.yandex.net (Yandex) with ESMTP id CD9E96012C; Tue, 11 Jul 2023 11:25:07 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 6PUZDhdWpeA0-R7j3s1K3; Tue, 11 Jul 2023 11:25:07 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1689063907; bh=JVtVuLOgeFfxBRVHtvOXE4rJ6XxxWw4GSNDfk+UNLV0=; h=Message-ID:Date:Cc:Subject:To:From; b=axPYPaG9lWuxRhqCY3emkHAxdVa1xYk+uhF34dTuIU+p5prYjsGQeApqHsu2qiEqo /cFGi4m4jTof0CAqc0YtevDtmgnFZ/CgBDpQOyKnHSYsXvOMusacD57kDhfWiXU+ns ITEzn86FfSj5de14+y6SdcFH2AcX8/2XVeRTbzIQ= Authentication-Results: mail-nwsmtp-smtp-production-main-39.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Kalle Valo Cc: Brian Norris , linux-wireless@vger.kernel.org, Dmitry Antipov Subject: [PATCH] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Date: Tue, 11 Jul 2023 11:24:53 +0300 Message-ID: <20230711082504.18838-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 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(). Signed-off-by: Dmitry Antipov --- 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; }