From: Geliang Tang <geliangtang@gmail.com>
To: Azael Avalos <coproscefalo@gmail.com>,
Darren Hart <dvhart@infradead.org>,
Andy Shevchenko <andy@infradead.org>
Cc: Geliang Tang <geliangtang@gmail.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] platform/x86: toshiba_acpi: use memdup_user_nul
Date: Sat, 6 May 2017 23:40:19 +0800 [thread overview]
Message-ID: <fac5b29b1e0ced6836e41c58f86da08ec523cc42.1493779654.git.geliangtang@gmail.com> (raw)
In-Reply-To: <6baf3aa45d0b5e0fd016b508bac905ebf8443aac.1493779294.git.geliangtang@gmail.com>
Use memdup_user_nul() helper instead of open-coding to simplify the
code.
Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
drivers/platform/x86/toshiba_acpi.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index d0daf75..88f9f79 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -1502,14 +1502,9 @@ static ssize_t video_proc_write(struct file *file, const char __user *buf,
int ret;
u32 video_out;
- cmd = kmalloc(count + 1, GFP_KERNEL);
- if (!cmd)
- return -ENOMEM;
- if (copy_from_user(cmd, buf, count)) {
- kfree(cmd);
- return -EFAULT;
- }
- cmd[count] = '\0';
+ cmd = memdup_user_nul(buf, count);
+ if (IS_ERR(cmd))
+ return PTR_ERR(cmd);
buffer = cmd;
--
2.9.3
next prev parent reply other threads:[~2017-05-06 15:40 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-06 15:40 [PATCH] drm/i915: " Geliang Tang
2017-05-06 15:40 ` [PATCH] ima: " Geliang Tang
2017-05-08 15:44 ` Mimi Zohar
2017-05-06 15:40 ` Geliang Tang [this message]
2017-05-07 11:42 ` [PATCH] platform/x86: toshiba_acpi: " Andy Shevchenko
2017-05-06 15:40 ` [PATCH] sparc: use memdup_user_nul in sun4m LED driver Geliang Tang
2017-05-09 19:16 ` David Miller
2017-05-08 7:29 ` [Intel-gfx] [PATCH] drm/i915: use memdup_user_nul Daniel Vetter
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=fac5b29b1e0ced6836e41c58f86da08ec523cc42.1493779654.git.geliangtang@gmail.com \
--to=geliangtang@gmail.com \
--cc=andy@infradead.org \
--cc=coproscefalo@gmail.com \
--cc=dvhart@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/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
all inboxes | Powered by JetHome®