From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Tue, 5 Nov 2019 19:09:15 +0100 Reuse existing functionality from memdup_user() instead of keeping duplicate source code. Generated by: scripts/coccinelle/api/memdup_user.cocci Fixes: 20ec628e8007ec75c2f884e00004f39eab6289b5 ("misc: xilinx_sdfec: Add ability to configure LDPC") Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/misc/xilinx_sdfec.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c index 11835969e982..a622fcf4954a 100644 --- a/drivers/misc/xilinx_sdfec.c +++ b/drivers/misc/xilinx_sdfec.c @@ -649,14 +649,9 @@ static int xsdfec_add_ldpc(struct xsdfec_dev *xsdfec, void __user *arg) struct xsdfec_ldpc_params *ldpc; int ret, n; - ldpc = kzalloc(sizeof(*ldpc), GFP_KERNEL); - if (!ldpc) - return -ENOMEM; - - if (copy_from_user(ldpc, arg, sizeof(*ldpc))) { - ret = -EFAULT; - goto err_out; - } + ldpc = memdup_user(arg, sizeof(*ldpc)); + if (IS_ERR(ldpc)) + return PTR_ERR(ldpc); if (xsdfec->config.code == XSDFEC_TURBO_CODE) { ret = -EIO; -- 2.24.0