Message ID | 0b7273a9720afeea6a42a10f38ebb09b6489adc3.1493381148.git.geliangtang@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 3783225130f01ea86fc0ee477a0e72c102ae2a4b |
Headers | show |
On Sat, 2017-04-29 at 01:45:15 UTC, Geliang Tang wrote: > Use memdup_user_nul() helper instead of open-coding to simplify the code. > > Signed-off-by: Geliang Tang <geliangtang@gmail.com> Applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/3783225130f01ea86fc0ee477a0e72 cheers
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index e5bf1e8..431f513 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c @@ -367,16 +367,9 @@ static ssize_t ofdt_write(struct file *file, const char __user *buf, size_t coun char *kbuf; char *tmp; - if (!(kbuf = kmalloc(count + 1, GFP_KERNEL))) { - rv = -ENOMEM; - goto out; - } - if (copy_from_user(kbuf, buf, count)) { - rv = -EFAULT; - goto out; - } - - kbuf[count] = '\0'; + kbuf = memdup_user_nul(buf, count); + if (IS_ERR(kbuf)) + return PTR_ERR(kbuf); tmp = strchr(kbuf, ' '); if (!tmp) {
Use memdup_user_nul() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <geliangtang@gmail.com> --- arch/powerpc/platforms/pseries/reconfig.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)