* + fail_function-switch-to-memdup_user_nul-helper.patch added to mm-nonmm-unstable branch
@ 2022-08-27 3:09 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2022-08-27 3:09 UTC (permalink / raw)
To: mm-commits, akpm, yangyingliang, akpm
The patch titled
Subject: fail_function: switch to memdup_user_nul() helper
has been added to the -mm mm-nonmm-unstable branch. Its filename is
fail_function-switch-to-memdup_user_nul-helper.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/fail_function-switch-to-memdup_user_nul-helper.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Yang Yingliang <yangyingliang@huawei.com>
Subject: fail_function: switch to memdup_user_nul() helper
Date: Fri, 26 Aug 2022 15:33:35 +0800
Use memdup_user_nul() helper instead of open-coding to simplify the code.
Link: https://lkml.kernel.org/r/20220826073337.2085798-1-yangyingliang@huawei.com
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
kernel/fail_function.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
--- a/kernel/fail_function.c~fail_function-switch-to-memdup_user_nul-helper
+++ a/kernel/fail_function.c
@@ -247,15 +247,11 @@ static ssize_t fei_write(struct file *fi
/* cut off if it is too long */
if (count > KSYM_NAME_LEN)
count = KSYM_NAME_LEN;
- buf = kmalloc(count + 1, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- if (copy_from_user(buf, buffer, count)) {
- ret = -EFAULT;
- goto out_free;
- }
- buf[count] = '\0';
+
+ buf = memdup_user_nul(buffer, count);
+ if (IS_ERR(buf))
+ return PTR_ERR(buf);
+
sym = strstrip(buf);
mutex_lock(&fei_lock);
@@ -308,7 +304,6 @@ static ssize_t fei_write(struct file *fi
}
out:
mutex_unlock(&fei_lock);
-out_free:
kfree(buf);
return ret;
}
_
Patches currently in -mm which might be from yangyingliang@huawei.com are
nommu-remove-uses-of-vma-linked-list-fix.patch
fail_function-switch-to-memdup_user_nul-helper.patch
fail_function-refctor-code-of-checking-return-value-of-register_kprobe.patch
fail_function-fix-wrong-use-of-fei_attr_remove.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-08-27 3:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-27 3:09 + fail_function-switch-to-memdup_user_nul-helper.patch added to mm-nonmm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.