Message ID | Pine.LNX.4.64.1005221021030.13021@ask.diku.dk (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index 4647484..08f948d 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c @@ -706,14 +706,9 @@ static int ib_ucm_alloc_data(const void **dest, u64 src, u32 len) if (!len) return 0; - data = kmalloc(len, GFP_KERNEL); - if (!data) - return -ENOMEM; - - if (copy_from_user(data, (void __user *)(unsigned long)src, len)) { - kfree(data); - return -EFAULT; - } + data = memdup_user((void __user *)(unsigned long)src, len); + if (IS_ERR(data)) + return PTR_ERR(data); *dest = data; return 0;