From: Hailong Liu <hailong.liu@oppo.com>
To: <viro@zeniv.linux.org.uk>, <brauner@kernel.org>
Cc: <jack@suse.cz>, <linux-fsdevel@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>,
Hailong Liu <hailong.liu@oppo.com>
Subject: [PATCH] seq_file: replace kzalloc() with kvzalloc()
Date: Fri, 6 Sep 2024 16:00:47 +0800 [thread overview]
Message-ID: <20240906080047.21409-1-hailong.liu@oppo.com> (raw)
__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 <hailong.liu@oppo.com>
---
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;
}
--
2.30.0
next reply other threads:[~2024-09-06 8:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 8:00 Hailong Liu [this message]
2024-09-06 9:25 ` Barry Song
2024-09-06 9:55 ` Hailong Liu
2024-09-06 10:34 ` Barry Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240906080047.21409-1-hailong.liu@oppo.com \
--to=hailong.liu@oppo.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox