Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp687431rwb; Wed, 26 Jul 2023 00:47:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHhcPBzrXreFOgtYLSy6MJhgskqn08v0KyLKsrcglaQoW3QbsIrFtG+K4Uto4dYbJIy1j3u X-Received: by 2002:a05:6402:32c:b0:522:1e2f:99db with SMTP id q12-20020a056402032c00b005221e2f99dbmr1053282edw.5.1690357637011; Wed, 26 Jul 2023 00:47:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690357636; cv=none; d=google.com; s=arc-20160816; b=TZ6gyJcCzG2KR5UEuU5Ok+11Puu6NQGFVZ34c/HddpEtd+MtzaxAlns7UeTclqfwKK IXB2wovBuxUnSq8o4+JNxlvCnrYuxT2dJ5e21NzhEJpUCagGQcQV+lY828B+w0PTGyG9 Q1o9ABYF2ToFRVKgRWU9d5YBtl/hu3ZJfqmzdqkR1XwZZdOJe59dzF7pBUCCmDB12Icw rE7Qg2KW4JmHkHo3AR7Ac8UoBo5J7FuQvEgwPxv2HSl6zlaqF9sO6uXptzdHf4uWezGF hbFodwOZw0OuEk75rek11OxoDvSiAqNJns8RJCbndczOKDNPZT0AR3Sikq7JTTjRQk1o JFIg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=NO40i8OOR61r7KLXzluQn5AjB3Vg8yqt8Yc8yNxfEuQ=; fh=o3fNsMfyqDni024pe6cTlbw1vzPM6MJMk4keKHZ8Hfo=; b=J0cf1o0lS1gfPLXxdhiwMtaoxzUxITTDsNx2IALJdMUevwDb4x11bMvW263ZnykQau 0Z64QUemKQtQypaFbruEqE3/m9svVevAwIlRzR4IZfeEp1xjM4+hDVKHyao0wRlZ8Sui Vv8p/VjU/URa2kxLcPoerUlzraBBGfc0/4wDSTNMem5RVUtSnYWHUVeH8uvjvXv5ZEw7 8lxgLjwE1Fh9cihe0nWE4a6t1rWRS0cfE30181AUNmDvK5aI5ZKrO/S3fKbj2ABoXs5V Hyq33cR9ayaKMUHxORN1P49f1aRbrOtvfMqJjb0yRnypfE35SFjLtgQpNG8ZXlblFSS1 eErA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=Hc2OA70I; 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 l4-20020a056402344400b00522299aed58si4677440edc.442.2023.07.26.00.47.02; Wed, 26 Jul 2023 00:47:16 -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=Hc2OA70I; 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 S232357AbjGZHYP (ORCPT + 58 others); Wed, 26 Jul 2023 03:24:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbjGZHXZ (ORCPT ); Wed, 26 Jul 2023 03:23:25 -0400 Received: from forward103c.mail.yandex.net (forward103c.mail.yandex.net [178.154.239.214]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 795D34203 for ; Wed, 26 Jul 2023 00:21:49 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net [IPv6:2a02:6b8:c08:a497:0:640:fcbf:0]) by forward103c.mail.yandex.net (Yandex) with ESMTP id 24D606004B; Wed, 26 Jul 2023 10:21:47 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id kLF1MPmWs8c0-138ylmzN; Wed, 26 Jul 2023 10:21:46 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1690356106; bh=NO40i8OOR61r7KLXzluQn5AjB3Vg8yqt8Yc8yNxfEuQ=; h=Message-ID:Date:Cc:Subject:To:From; b=Hc2OA70IsFhnTxqdBgPIKcmWLBu/MEbaJOd9vmoz8fpIiYzAApZRhhdeOg1AYSPnS IAJ+ZeILo+o1p3udov+FKamPaRDJU620A4ldKuBfBAKjhjQ3yrxYcO12Y/YvT2lX+U A+hSGqq2J8WqYgZDsknJGtV4Ghl7crh8U8cwHATk= Authentication-Results: mail-nwsmtp-smtp-production-main-36.sas.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Kalle Valo Cc: Brian Norris , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 1/5] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Date: Wed, 26 Jul 2023 10:20:52 +0300 Message-ID: <20230726072114.51964-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 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_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: cbf6e05527a7 ("mwifiex: add rx histogram statistics support") Signed-off-by: Dmitry Antipov --- NOTE: this series supersedes all of the previous mwifiex patches not yet accepted into wireless-next tree. --- 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