Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp940160rwb; Fri, 28 Jul 2023 02:07:00 -0700 (PDT) X-Google-Smtp-Source: APBJJlHbMiQx+KFS7jGk9xsDQen4SgbMowpJqvgUFltBkVRYEVYvSA9oIsd/D+IRzsdwFNR/9Sv7 X-Received: by 2002:a17:902:aa41:b0:1bb:c7c6:3454 with SMTP id c1-20020a170902aa4100b001bbc7c63454mr832645plr.48.1690535219557; Fri, 28 Jul 2023 02:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690535219; cv=none; d=google.com; s=arc-20160816; b=UHV8IjC++SQFRnejlBP3oMKO66R871dAg6tJ/v1rCqzUeeFDl5RE50tpZpRNdMq/oW XLvyJnRjfG8tAiEI44C0lvGlULhYvBpFX8CNeRegiR1oqEdagF2w8380TDWOwinVNlOK MUrQUwaXPBgG5uZoCOAUpKN5OX4oGHCH11Pe5IsGJtbkBFe10twQY7gth6+l4rHW6k6A x6pNxnBVP0N69MkAMk/R62KykLVQuNPMo6xW4PpBp+76nvPrINYrnwCtm3Qk+BFwbd5a uLRQipRcD/+UNIQR+3Wc29jVTxdOv4t9OJm5RbTf8v9TEvV+5aqEIpI06aEtBzQPbzIT 5tlg== 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=Vqd1fIm4opR6T+gRXreNBK3yFF7TA3juAjlFt+PEyrU=; fh=qNTNQJCwXPXlkhMjfcbW5RmVTNlOQmtiwNfLT5XSKFo=; b=nIWp6iJ0SERkwc08mnj0mjP53/p2Um2YCh9rZq5Om3bKLWxJ0cnuAtZl+lpKkn4eR3 0gvppr5qcU5R37aYToaT+upkamQFf4XUjLQel38SJnLEfHZvhaI8/l5+JIfbIJvzhlQ2 KuAVvXWuV9CtG61yXtz1q+rILjcBsivD278t3U+xQm9+FEoyZ6uv4YQTfgxONGuu8h2c CRA46BAaDEXXgslKOeFDgobYqhSI7qTZiPejg10UUEIYFoXlPKObTbNJZ8zrk0nLQwrD mFrqCkFn6PzDano4pXuDzOtEMu0ZFewABv6frchZrhVjWZSHF4yTQ+Lg7NOycZVZW0H4 C/uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=TMKDY4r1; 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 o5-20020a170902d4c500b001b9e1d5f8e6si2865504plg.447.2023.07.28.02.06.44; Fri, 28 Jul 2023 02:06:59 -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=TMKDY4r1; 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 S235102AbjG1Iog (ORCPT + 59 others); Fri, 28 Jul 2023 04:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234380AbjG1IoT (ORCPT ); Fri, 28 Jul 2023 04:44:19 -0400 Received: from forward100b.mail.yandex.net (forward100b.mail.yandex.net [178.154.239.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2644D26A0 for ; Fri, 28 Jul 2023 01:44:17 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:a712:0:640:d986:0]) by forward100b.mail.yandex.net (Yandex) with ESMTP id B2F3160110; Fri, 28 Jul 2023 11:44:15 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id EiIwG59DYW20-Wa42w8E9; Fri, 28 Jul 2023 11:44:15 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1690533855; bh=Vqd1fIm4opR6T+gRXreNBK3yFF7TA3juAjlFt+PEyrU=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=TMKDY4r1pUdabGb9xrDcj2Vmmzt7Wd3SOMP8XEfEDzTmCPBw6/TCqZSAN2q19IhY7 BzhMlqyEa0NRY+mp0T3EbeRhkE8gafAFEScpZ9/h33UEa4j/P+kniWLw05JkCVDC2x 9Ae+BRnidDUxjNTMSRzxW26cYIyzs9fkWSgt+/To= Authentication-Results: mail-nwsmtp-smtp-production-main-18.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Dmitry Antipov To: Brian Norris Cc: Kalle Valo , linux-wireless@vger.kernel.org, lvc-project@linuxtesting.org, Dmitry Antipov Subject: [PATCH 1/5] [v2] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Date: Fri, 28 Jul 2023 11:43:42 +0300 Message-ID: <20230728084407.101930-1-dmantipov@yandex.ru> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: 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,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 --- v2: adjust to match series --- 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