Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36487073rwd; Tue, 11 Jul 2023 01:25:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlHfojATdbr7+NZYp5AIKAribjx27uncFGfL6jjt7MKFCWXBfgAV3aPFo27BQ7C4PE5mJE98 X-Received: by 2002:a19:381a:0:b0:4f8:5905:8e0a with SMTP id f26-20020a19381a000000b004f859058e0amr9835697lfa.6.1689063947912; Tue, 11 Jul 2023 01:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689063947; cv=none; d=google.com; s=arc-20160816; b=LUNY5zYpSbvopA+WHkhj7g2ZXgUWwNwRq/oW9WdywdvG6/fytbW8Yl4vBvrbhQwjn5 thibdPMsElRHz3PC3yClzfrbzD6ArQjvWixAuP/O5KDKmxAeQ8xTn2qWwMmZbhMypi6P ptEEYMFryt4u0hkL1hReJhKhKG/820HR6jsBEotJ2fWOtZTWTPFxnKLxKPllzEg5Z9XO uzsnNi2v0RBL2p9M8YMG+60UnDjH/W+Llr3khZ57QtCDEqWH+X3aEi/+Q0biQy7BetRV /GdWnAQQ3VTZMwSAglMU14b1YBtpznJ+bh8L0J7Feg5maXkJM6dZDyXzNNyqN53kNAfG XtCw== 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=JVtVuLOgeFfxBRVHtvOXE4rJ6XxxWw4GSNDfk+UNLV0=; fh=IRXrTwT0owVgYy98Gpa0pXop4YjMVygPdaWudd9VUko=; b=x+xnzT2rQqIjbrRbNxsct9HfXNGvp6s1V8mrykBGUGbI++TKz9MEOZvcfCtAsDCrtb lJGpLVylYPAjHLmxg1Ee95PrZMxq1OUObDqEuacPAjhywbV1ZrB/FYfPSqWjQ/2QmN2H CsEQPeDg/bIbgTIVn6Nz0l6ghk68EscVORyMHimZxn120X3VUdWIXbsh2+y3qgcLB2kF JI+195bsl+4PnOQIdZPXpf++9/zGyc/YrJox0N7CD4msKomz5B8HsQyuw36JgTvNsI8f ZXC42GIkRpeAm4pFN0rCdlvpwkEb6sS/6TNMpf5km+92b+SIPAqK4cxoeKq7uRWTA/Il 3oTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=axPYPaG9; 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 n22-20020a056402515600b0051e109a50a3si1461651edd.527.2023.07.11.01.25.32; Tue, 11 Jul 2023 01:25:47 -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=axPYPaG9; 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 S231215AbjGKIZR (ORCPT + 60 others); 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 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,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(). 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; } -- 2.41.0