From patchwork Fri Sep 6 08:00:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hailong Liu X-Patchwork-Id: 13793643 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18846CE7AE0 for ; Fri, 6 Sep 2024 08:06:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DECD6B0085; Fri, 6 Sep 2024 04:06:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68DE26B0088; Fri, 6 Sep 2024 04:06:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52E506B0089; Fri, 6 Sep 2024 04:06:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 363BE6B0085 for ; Fri, 6 Sep 2024 04:06:00 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D5E27141058 for ; Fri, 6 Sep 2024 08:05:59 +0000 (UTC) X-FDA: 82533580038.26.1948045 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2085.outbound.protection.outlook.com [40.107.117.85]) by imf11.hostedemail.com (Postfix) with ESMTP id 7BC3E40016 for ; Fri, 6 Sep 2024 08:05:56 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=VwT3cBJR; spf=pass (imf11.hostedemail.com: domain of hailong.liu@oppo.com designates 40.107.117.85 as permitted sender) smtp.mailfrom=hailong.liu@oppo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=quarantine) header.from=oppo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725609932; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=Q+OIR6AWe8p2W2fsUfWGLOPJMYgugfQ+9Xs8aBn3Nw8=; b=4+2+oDorkJYmrW04nA3B0C9SmiqQO4TPYzFe9gwgw0vvSHCX4w/Ax8mExqY5ewdRCayyfm TZ4ZdcmAA+AWx84MupfLqkWbzdh+vG+XLYpsuFbAp0AXpMtSwTypv8og33TCvpG8Ui9Tv7 wdRKB7Zlq7DTNWbw/NWGfa9Hb0Qi4vQ= ARC-Authentication-Results: i=2; imf11.hostedemail.com; dkim=pass header.d=oppo.com header.s=selector1 header.b=VwT3cBJR; spf=pass (imf11.hostedemail.com: domain of hailong.liu@oppo.com designates 40.107.117.85 as permitted sender) smtp.mailfrom=hailong.liu@oppo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=quarantine) header.from=oppo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1725609932; a=rsa-sha256; cv=pass; b=7pRsTome/3oXGiBEhE3wjMkK3uXY27ILgNqZdJWlwyI/VDuzJBVrAIQMgnl9AJpQnHomdz l6DnoJ9ZxQMtj/OW0vI0z8SakDTRGMStKGSOwSyrBm+WW2U9TwKFBRkkmnlJZAAVW0pczQ idCwnMQfd5IuXnKwcz3mFHOnsRUL3Kw= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sD4+QTDmhR7dk1RJaGqwzr0r6QHbX5GJF6aVjDUqJeGf9NM4Llkrt5f+a0klRUQ8qYxaav8ijdbT2ey6h+eFrnM2hXg1G9mlrMZHIT4O7dI4KIytcw5ncxjzXzzHX+xCxKREYKtCkw0gk4cyPadwxDH19zd2laOlMbiwvPMWDJxvI0bVs2hLcH1PVpgdPAtvZWUr0FRtS9kQ+iEbNyRURvVADBaq4wQHTnfP/QjaHkeGKhqA3qoLcKBkmrHNwy7dCZhRlYovqyVtnnVMgX94sIbm56RgH/INcgsCBLPKs6MPDKaodKdv5dfU56+kmlXqo+rQHra8y5EYfU0X2BW7bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Q+OIR6AWe8p2W2fsUfWGLOPJMYgugfQ+9Xs8aBn3Nw8=; b=Ju250GVDQjtCwmnq2ht3M70ZD3OJgHiCuaf8krGdGhPBLCB+9xAfJ7E69bYWIt4EukWvKhzwnowdJr/Lih+1sNByPP5Bwmeovvi16A62j8uliiJLkzSYUMT8EYS1hWZ7I6XRiYH5qOBloKIysr1uB+3aqDAauNzeB5/KnQB88AtetbThiIuLAU8UHCREPRQBz1f/iZd5y9NmBlcY8E9+T8ujB0bozqjFUBRKx+q/8DCqooPuxEevC/OMq967OIcAseIAQqIem5VakGo4zQT6IE1sbomUVfVAomlcgf1+G3Kfwc8MoAEh/JyvT/sa0RFoNudVLx/raAJ1SUlL/n37Ug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 58.252.5.68) smtp.rcpttodomain=zeniv.linux.org.uk smtp.mailfrom=oppo.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=oppo.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q+OIR6AWe8p2W2fsUfWGLOPJMYgugfQ+9Xs8aBn3Nw8=; b=VwT3cBJRv4v2q1xO5jmYW+ShIiZMjdoNfFLmSFyOx9LTiT/HZBomkXUelsP1jHDxH2tika5Sn1AXm3KLuKxKqBWzvZq6gRwpSbtpCtfJsDLKt5pdntOFSUvBIYVnZXmVI7RkBAF//fDjB+iaLRrCehMzZCXCBGrbbt1KHJ1X41I= Received: from KL1PR01CA0088.apcprd01.prod.exchangelabs.com (2603:1096:820:2::28) by SEZPR02MB6988.apcprd02.prod.outlook.com (2603:1096:101:19e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.27; Fri, 6 Sep 2024 08:05:50 +0000 Received: from HK3PEPF0000021B.apcprd03.prod.outlook.com (2603:1096:820:2:cafe::87) by KL1PR01CA0088.outlook.office365.com (2603:1096:820:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.17 via Frontend Transport; Fri, 6 Sep 2024 08:05:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 58.252.5.68) smtp.mailfrom=oppo.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=oppo.com; Received-SPF: Pass (protection.outlook.com: domain of oppo.com designates 58.252.5.68 as permitted sender) receiver=protection.outlook.com; client-ip=58.252.5.68; helo=mail.oppo.com; pr=C Received: from mail.oppo.com (58.252.5.68) by HK3PEPF0000021B.mail.protection.outlook.com (10.167.8.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7918.13 via Frontend Transport; Fri, 6 Sep 2024 08:05:49 +0000 Received: from PH80250894.adc.com (172.16.40.118) by mailappw31.adc.com (172.16.56.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Fri, 6 Sep 2024 16:05:48 +0800 From: Hailong Liu To: , CC: , , , , Hailong Liu Subject: [PATCH] seq_file: replace kzalloc() with kvzalloc() Date: Fri, 6 Sep 2024 16:00:47 +0800 Message-ID: <20240906080047.21409-1-hailong.liu@oppo.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [172.16.40.118] X-ClientProxiedBy: mailappw30.adc.com (172.16.56.197) To mailappw31.adc.com (172.16.56.198) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HK3PEPF0000021B:EE_|SEZPR02MB6988:EE_ X-MS-Office365-Filtering-Correlation-Id: f6f6c97c-eed7-4d98-b988-08dcce4ab849 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|82310400026|376014|36860700013; X-Microsoft-Antispam-Message-Info: 5B7ri+O0h9RgcKjdKhRfsgqVQGT6SaoUsxohL8TpHrmVTRNYhVQwBdJuqaWUS2okn0n3lTb/VfCdn4BHv92sRZhZaiis7W30/YDI8/lgMguU9S6tymD0Jva2s845G/gqbngDmkLiewPiaZ/vaiDNmK9G7Wf4C00xUuE5tj9FShNJSpEtRAtYRxZ0ntZFLLYGjxCtnJeyUY3bwkf8lA73FVcFuIwNa6Ri6TknfFOfq52Syp+rYNtaekpJyUCONki8eUumQzyZjx3MAOuqnAIF3WT3XtSeAmzKww2Br9Qo/hysICTb6O0g+tuPyWK0jjYkAAYbSP5tT8Ytk5Mjn/xyEjiK6Axmhll7ipr9QrvFPiOKknG6Wy73Bg1AKIjZ1Au1hK4fAHbCOhgzy48StoyTWeB2YrLOuuHYaNQTxDWp4MGT+nacKMJ5PDmz5DzwjtqsSwsXzIgF1KZiz9Zw1YrWpfHxQVHnIkULRPP9BmbKFSv2k1TziHHFaSv84+jgRqbqTNly5h6Xx5h8hcXUYvE/AV2zwwVLGVz295y6cRVOUZfMRfdNyWgg507y9lp9h3zOl+tDyP7Spu6ATXhz7j5MLR1XRyGZz5rtAqubLMCJO7lPoo3406nB/S6Sh/rK/1ABMavQZKgu3irCMaq8x/Yskd+kzLeB427xR8x2c0M65WljcAU60/oV+8rya4tTArAxhSbwtzlIKp+qHSo9Xqp/VfjCzjd54oeFWB68Hjw8yCQkRLg22TBHzZOHnfiOpgIBQ4fuFGAR3Q0n3ZkaeHO5oQDHyP2IuAQ+Rg7LHWyoHfOZBQ/Mnbl7yZz75UtlcGSilHogOUSvoyu0JGYmzgqh62iKKwUfNd/tN4N2srPtiUTK42PQH7NmQ+YMg1gi7VFt5EqaT4Oq4rLDuQn7cRPjRQQau8T2RnQ6P0lwQlvn+wYTkr+JjMS2sOlU3exww/P9wglDmGMw1Vxp/pp7IFhiHCyxs3wWOu3vuWZtBCZNy+4jd+l9QRhHzFZZr9g9bn4UBiqkcBeNkgkd07uTw5ZV80yffS7jdzc38KjkBuzS26H2OzmcXd7+6qt4KN5CR+tNjaFlXWnATq3YxfolDw3NmqaNSdJCiqNRjSjxH+RA0RA1SO9lDTA7z+0BkqQO2uBx7L7R3Lo8Eb/oHH3AFeJDSAbrNr3qAOLS8rN3xBnksdCMUwPrxK3YboS2HlHk+pBi9MipJISN6JkUOvTmIn1ZhBVO160XNL8ykEqncGubCsdLtNfuTlXPOOpTisVXDY1oGrMgYdKWIELo4/Bmol2sFBiFatrFKZhsWz0JH0pMocPGGGWk7x6SVkyxw/qxtl17KcZARgjvi9pTxKnDIty8M5Kx4MY5N/Z9zSV229ccLLXW0dt8fhl0HWYwpX8gO6/97ggz4mJ5+BWEHj2rx/oTEnSu5cGqiUnWslemgs/tYStvne4BHxhyOmJ1sbUXrtym X-Forefront-Antispam-Report: CIP:58.252.5.68;CTRY:CN;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.oppo.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(82310400026)(376014)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2024 08:05:49.2946 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6f6c97c-eed7-4d98-b988-08dcce4ab849 X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f1905eb1-c353-41c5-9516-62b4a54b5ee6;Ip=[58.252.5.68];Helo=[mail.oppo.com] X-MS-Exchange-CrossTenant-AuthSource: HK3PEPF0000021B.apcprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR02MB6988 X-Rspam-User: X-Stat-Signature: fk3u1cezg8d5pfe7tw1n755ts1db31yq X-Rspamd-Queue-Id: 7BC3E40016 X-Rspamd-Server: rspam11 X-HE-Tag: 1725609956-699725 X-HE-Meta: U2FsdGVkX18nDt9jez4FrKLWsSraU+9ud0JCGwjBbqT49emSOQ9CiaLez6U9AIWLnnr2tWs15FOeVhnCABzMBcejL/nVHcQxUY7XpAKAoa9nXz9ReWtHc1uvmeuyInR7TNXIFauzlkt7crwCEjvLwLNmbvOwaI1+eiFUStwaF/cyeJ3z7bmIdxID3zltfF4aB+yJvJ8FtVRCxyuYEyeecTizWIz6uPXz2xyTBb+4YXr2IqfuczBSHmYbyMSJoe2Yy10gBgiyBcBfRh5LfYTaSwxyC7BxAX7ChqIzg8r9muava9pu+c/W+mI9sDQBxy9iQcYgYdJ2iv4ApTjaRt7KaWYGRN1C7Af+51QxmlZQs6lUQT5beh7i8lzxSxdJoyjUH7/Vv9Vfxkz3HFpB3ATALW2qqoAWEAbi+YQy+oRzjV7Hm6Nz8yAfo66U4Ppa80w0ZPaImuDBqvkRannXYxdeU6MvtZ4InShgWmTVq97aqn2/LGq/ye+RGwuA57gfNZAwS0L9vSDal7SqEsWGnLm76Y30ntKi1y81LEwPVY5A7iPdFToH/2AcIgWbWqOL3VPrm9luQi5V6G07xykOx5ktQHb2+qr/WX91XTbSmJoJ1dRa5SJsM3oMqtINBGwZ2oNx2dhDVm7kW50cqoJmX3oIVuOYb/V1FLihGRE6UzAdZq6uleDwa1qdAwQ0dhkeLh9k9UeCW/5IrsF0X7eM9METiLjglSWoi/RzcBu7d8Q6Eg4eTuR5by61ffjGVF7L3RS3zK0eJCLQAdXAGXOqXobiOKZfiiQdtAtYfW5B/17z1PMI3WvKCJcXpmRircDJAxYfCzAKhINKCIzhODYA9Umc/+ds7mOGFExBnFslNGQhYX6Ar4yRtYj9IJGDwPtu1iJ7zcj4XA4AVLfPyNJkE2y/lLK+7R/LSCR1EPem26EqjVbgxoelmuEAPaN4sXkRMzQHl9NcoTL6rzJ7f5J5Luz ZNw5HZdg LEQm0XT42bLuN5Y5N53zG4RVDwBrAyBAsJ/0ul2FBf6PEd7Za9qu3KpCTopW74eaVrxWMQFq/qBRRPUPhf9FTmnycc2zLX3yDZq7yPXfQG6BnAss9CqzMxHGSLWAbRJ3Lf/cFDo7FEFWbNmdcXJ3yot4wkvvi4maagevGVxLBpcrQnkivtmz6HSBCGBjes7YDq6YZRfODwzCPTry7KFMPmBBpdnG3lz+dzM1etQ6uhc7ZLYDNHP0AgsiacmPs9XxIUX4NIr8vXN2NuFqPZpmEOhVw/T1hNhJ4z20R+oZDzJm60Z8/zlYrvMw7fAsCZPI9yA3TB4t67IzbjfLdQf2BuWmje9lE7xfqyyuZu16sU9D0zMM51Xe1c9mDUKzcgzVxzATRdm2YFLJvTJeT45CQvmdnqc8kxvP2XWeR7nsImVHzn4ezai7HVIVQgLRzAodjMwNA08R0LxpDz90= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: __seq_open_private() uses kzalloc() to allocate a private buffer. However, the size of the buffer might be greater than order-3, which may cause allocation failure. To address this issue, use kvzalloc instead. Signed-off-by: Hailong Liu Reviewed-by: Barry Song --- fs/seq_file.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index e676c8b0cf5d..cf23143bbb65 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -621,7 +621,7 @@ int seq_release_private(struct inode *inode, struct file *file) { struct seq_file *seq = file->private_data; - kfree(seq->private); + kvfree(seq->private); seq->private = NULL; return seq_release(inode, file); } @@ -634,7 +634,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops, void *private; struct seq_file *seq; - private = kzalloc(psize, GFP_KERNEL_ACCOUNT); + private = kvzalloc(psize, GFP_KERNEL_ACCOUNT); if (private == NULL) goto out; @@ -647,7 +647,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops, return private; out_free: - kfree(private); + kvfree(private); out: return NULL; }