lkml.org 
[lkml]   [2021]   [Feb]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v4 4/9] cxl/mem: Add basic IOCTL interface
On Mon, Feb 15, 2021 at 05:45:33PM -0800, Ben Widawsky wrote:
> + if (cmd->info.size_in) {
> + mbox_cmd.payload_in = kvzalloc(cmd->info.size_in, GFP_KERNEL);
> + if (!mbox_cmd.payload_in) {
> + rc = -ENOMEM;
> + goto out;
> + }
> +
> + if (copy_from_user(mbox_cmd.payload_in,
> + u64_to_user_ptr(in_payload),
> + cmd->info.size_in)) {
> + rc = -EFAULT;
> + goto out;
> + }

Umm... Do you need to open-code vmemdup_user()? The only difference is
GFP_KERNEL allocation instead of GFP_USER one, and the latter is arguably
saner here... Zeroing is definitely pointless - you either overwrite
the entire buffer with copy_from_user(), or you fail and free the damn
thing.

\
 
 \ /
  Last update: 2021-02-17 11:38    [W:0.105 / U:0.352 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site