Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp667819rwp; Wed, 12 Jul 2023 21:47:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlFyrF//7AN1pza+pBWcU0yjTvEmoxz2/YzeMTSeTeSwcP7fYnKr9wLiE/xx+gFFnp+JGwDQ X-Received: by 2002:aca:6286:0:b0:3a3:6d15:930b with SMTP id w128-20020aca6286000000b003a36d15930bmr502132oib.50.1689223621856; Wed, 12 Jul 2023 21:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689223621; cv=none; d=google.com; s=arc-20160816; b=cndrXYOsfIDRDqiBM/RahYa9x/ZqWHlosadqo89+bWc1u1nK1NcYjkCMvJ002txL1p yuACdwYM4PcOnyIM4NZSM3Hk8WUKiAewnQ+4GxZABSvBRaoRgWUwVCV3AndxaDpxLOfT U3Nm7NXzshClxpJ/a6UmSS8IGuJb8fokcVEIDQYsU5jnf3LOJctGsiLyUlkmf2id0ao6 uvpWDNzaj/OkRlGuKa/+4CgNm7B7aqV8ai70axsLeRS//+CU4/03ZTmagEJ5xlLCJ6K6 BscTmKqTunVqT2FIHEC/SM56wi80l9hC2CuUvBjicv1l8HJteY3ltnjHLTQAUaX4EGRa uw8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=cMdW4WRtGi9MWXlD0+g6bIkYHAToqAiodESle5tVj5E=; fh=E/JEDdF2QiXRccUR0erhNyaXwcpxNdN0Zwyu4muECLk=; b=uW4LBkcAqDEIFQ+pDJ/Zv8UMIhDQpkB3iF+IgTIyNC1jgdmlpy6bUk7ZLeW7tir7c+ XcH4PFJpMs+btEBNc4Eb9+afdmZUtWn5gbCSrdkD34I6Qr+1akKFRWV34JK0BuGo9lqz whvaFL0PsMhkYJoxZktDGmfYm/1PEDZw549Yc/9W/ayA8RyjgjJ6DJeOTwwsd9TxGn0W iOGZVYpHlFUK6jn4uaGxx6kUeqHa0H/lmde3yY/WXCIynU0yW3sjEZczYIfttCHBnJdo tTvpSXDN617qumQWNix79a1Phz0BYRG0Yj+D4ra3Ivz+pumiWa2ESC2HjJepAxfm5JM3 hGXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=wRnC6JG1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s68-20020a632c47000000b0055ae20ada77si4360793pgs.591.2023.07.12.21.46.50; Wed, 12 Jul 2023 21:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=wRnC6JG1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233446AbjGMEo7 (ORCPT + 60 others); 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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; } -- 2.41.0