mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
libfs: simple_transaction_get(): replace get_zeroed_page() with kzalloc()
simple_transaction_get() allocates memory with get_zeroed_page(). That memory is used as a file local buffer that is accessed using copy_from_user() and simple_read_from_buffer(). kmalloc() is a better API for such use and it also provides better scalability and more debugging possibilities. Replace use of get_zeroed_page() with kzalloc(). Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Link: https://patch.msgid.link/20260523-b4-fs-v1-8-275e36a83f0e@kernel.org Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
06040e7520
commit
02d7d892d2
|
|
@ -1258,7 +1258,7 @@ char *simple_transaction_get(struct file *file, const char __user *buf, size_t s
|
|||
if (size > SIMPLE_TRANSACTION_LIMIT - 1)
|
||||
return ERR_PTR(-EFBIG);
|
||||
|
||||
ar = (struct simple_transaction_argresp *)get_zeroed_page(GFP_KERNEL);
|
||||
ar = kzalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!ar)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
|
@ -1267,7 +1267,7 @@ char *simple_transaction_get(struct file *file, const char __user *buf, size_t s
|
|||
/* only one write allowed per open */
|
||||
if (file->private_data) {
|
||||
spin_unlock(&simple_transaction_lock);
|
||||
free_page((unsigned long)ar);
|
||||
kfree(ar);
|
||||
return ERR_PTR(-EBUSY);
|
||||
}
|
||||
|
||||
|
|
@ -1294,7 +1294,7 @@ EXPORT_SYMBOL(simple_transaction_read);
|
|||
|
||||
int simple_transaction_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
free_page((unsigned long)file->private_data);
|
||||
kfree(file->private_data);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(simple_transaction_release);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user