Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1141764rwo; Wed, 2 Aug 2023 09:16:13 -0700 (PDT) X-Google-Smtp-Source: APBJJlF75uj+qmzWNDor2eE31Zyho45dJpyJWd39oZVRKH8SirZqLXXvfgXxedIjlYwrYnm/ja2D X-Received: by 2002:a17:90b:4f43:b0:268:6b9:c7ab with SMTP id pj3-20020a17090b4f4300b0026806b9c7abmr11838251pjb.48.1690992973508; Wed, 02 Aug 2023 09:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690992973; cv=none; d=google.com; s=arc-20160816; b=ua63Mw0HBBKXjZ1vIJihSwvOGkHtEcBLXWYJekNJTfpKpNn/UxNhtQfbStDlz7Yq+/ whgCKQs7+HQlDt9CHcCsKOf6sF1qCUmuOhgMl5/U5vsQdUULQfyQ5y/hcchMFk5onN82 +mx66Jxd2AGwEMdkHH4+GkbTSxCiqzRrYziRyVC0+rSQlUrvB65aZSjtAcO7XPztnKAa /fsB2T8DgoZaylECWDsAJp6s36OkLK6WDj0hPyovZHO/ev20a0FOt6MsWYuicpRDNa3p CUSazipGvgqLXWuKl1mBrGi9JUkN8UTGIo3kobwEXBr7kS04165l8NRHLNyj9uu+sQCg vIaA== 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=kvvtDSm2h2CJBcPppS7r0tHYrjrnkTlwna1aO4EI7N0=; fh=qNTNQJCwXPXlkhMjfcbW5RmVTNlOQmtiwNfLT5XSKFo=; b=ODTrX7FRDR1a77/5b9gQcbVfByi5RL3VbOIJy3w5BfzQqX7M/dAvGrVE0QR2K9ola4 2bIJT0akFx0yRpjx3AEfJexmTSVP3kRhJilp0scxZbMYQaBqBcuan8Rbwn2hr87wcMQ5 hjXrSPNenGuMNpQs/47oCquUzq3BUml+StSVxgv2Tnn6iES+Id0WDUPg8r0DRrs4euxG uhImsSykVRZpzb807PemJ8m6teur+StGsUs3p6sVIeGfrTIfp2Q/0J+8bVM8lnK2tsxP 3suUR01U1hWd/16AyQugvHUf6Rgh2GFUq2z6XqKYvuOK72fezpGiYLg+5Jnuo2CB5jzj XCFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b="GLKP/RCb"; 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 r21-20020a17090b051500b00267668f8be7si1423306pjz.64.2023.08.02.09.15.59; Wed, 02 Aug 2023 09:16:13 -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="GLKP/RCb"; 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 S231203AbjHBQHn (ORCPT + 58 others); Wed, 2 Aug 2023 12:07:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232144AbjHBQHj (ORCPT ); Wed, 2 Aug 2023 12:07:39 -0400 Received: from forward101a.mail.yandex.net (forward101a.mail.yandex.net [178.154.239.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37CAE1BC7 for ; Wed, 2 Aug 2023 09:07:34 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0f:26a7:0:640:a2d5:0]) by forward101a.mail.yandex.net (Yandex) with ESMTP id F1C4E46C52; Wed, 2 Aug 2023 19:07:28 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-84.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id S7VxvrADR8c0-XHyDf7HY; Wed, 02 Aug 2023 19:07:28 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1690992448; bh=kvvtDSm2h2CJBcPppS7r0tHYrjrnkTlwna1aO4EI7N0=; h=Message-ID:Date:In-Reply-To:Cc:Subject:References:To:From; b=GLKP/RCb8TuIDcP2HFolywCrSq0zE2K5h5IaksmFZ1NFFfKahjIKYLnzBHiY/xQjU +k4Hw6v/04K3j8UQEO+fhMDXkJLDZUa9sOiX7PRImWV65dDTSGTHew2xUIZjPJtrar 7e5pE1X8Ny6UKokkHf7raBFXvEPc1WAfWIOjpFHw= Authentication-Results: mail-nwsmtp-smtp-production-main-84.vla.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] [v3] wifi: mwifiex: fix memory leak in mwifiex_histogram_read() Date: Wed, 2 Aug 2023 19:07:15 +0300 Message-ID: <20230802160726.85545-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, RCVD_IN_DNSWL_NONE,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") Acked-by: Brian Norris Signed-off-by: Dmitry Antipov --- v3: add Acked-by: and reorder 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