mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
proc: replace __get_free_page() with kmalloc()
A few functions in fs/proc/base.c use __get_free_page() to allocate a temporary buffer. kmalloc() is a better API for such use and it also provides better scalability and more debugging possibilities. Replace use of __get_free_page() with kmalloc(). Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Link: https://patch.msgid.link/20260523-b4-fs-v1-2-275e36a83f0e@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
parent
6c519166e1
commit
cb7907e36c
|
|
@ -261,7 +261,7 @@ static ssize_t get_mm_proctitle(struct mm_struct *mm, char __user *buf,
|
|||
if (pos >= PAGE_SIZE)
|
||||
return 0;
|
||||
|
||||
page = (char *)__get_free_page(GFP_KERNEL);
|
||||
page = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ static ssize_t get_mm_proctitle(struct mm_struct *mm, char __user *buf,
|
|||
ret = len;
|
||||
}
|
||||
}
|
||||
free_page((unsigned long)page);
|
||||
kfree(page);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, char __user *buf,
|
|||
if (count > arg_end - pos)
|
||||
count = arg_end - pos;
|
||||
|
||||
page = (char *)__get_free_page(GFP_KERNEL);
|
||||
page = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -371,7 +371,7 @@ static ssize_t get_mm_cmdline(struct mm_struct *mm, char __user *buf,
|
|||
count -= got;
|
||||
}
|
||||
|
||||
free_page((unsigned long)page);
|
||||
kfree(page);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
|
@ -908,7 +908,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
|
|||
if (!mm)
|
||||
return 0;
|
||||
|
||||
page = (char *)__get_free_page(GFP_KERNEL);
|
||||
page = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -949,7 +949,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
|
|||
|
||||
mmput(mm);
|
||||
free:
|
||||
free_page((unsigned long) page);
|
||||
kfree(page);
|
||||
return copied;
|
||||
}
|
||||
|
||||
|
|
@ -1016,7 +1016,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
|
|||
if (!mm || !mm->env_end)
|
||||
return 0;
|
||||
|
||||
page = (char *)__get_free_page(GFP_KERNEL);
|
||||
page = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!page)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
@ -1062,7 +1062,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
|
|||
mmput(mm);
|
||||
|
||||
free:
|
||||
free_page((unsigned long) page);
|
||||
kfree(page);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user