From patchwork Sun Jan 28 14:35:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Elfring X-Patchwork-Id: 13534489 Received: from mout.web.de (mout.web.de [212.227.17.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83B8A210EC; Sun, 28 Jan 2024 14:36:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706452566; cv=none; b=DFPBdQgZd3WmpsfiLu2iEJqFWlL1JA0fU2ZKYTDSjO1E3sUSfkIcgPpP1sAYaLhGxx4A/7gOTqjRh0F1tUa/0uDlBqGX5lfnEE2ijya9w/y9fAHhHE4LIT44x6pvh3Q6ug8biuNB+7R20dTQUqZ888FJVVehFgOev5ypnm901mY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706452566; c=relaxed/simple; bh=aDhTgz/lX7Bkp3K6CN8opRhhDbmP/3uNFck7LgFe5CU=; h=Message-ID:Date:MIME-Version:To:Cc:From:Subject:Content-Type; b=SHoJGbxpB9jKHkQs0Pu7ViYM1jI8HMTvc8kqVBPTZQR4Q4DbTYZjzBBshUrVlG8HlK9UQsLOgfTr4Hi0zvAc7Bn6MZIlVrDeqfJRByNEIERHoGwC3mNHdsHdI3sLMEOMywp3VlPKjE2NkzW6FoD32OSlmAvB9mtzMeNWfJ7WfNo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de; spf=pass smtp.mailfrom=web.de; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b=VO8NY6o1; arc=none smtp.client-ip=212.227.17.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=web.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=web.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=web.de header.i=markus.elfring@web.de header.b="VO8NY6o1" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273; t=1706452523; x=1707057323; i=markus.elfring@web.de; bh=aDhTgz/lX7Bkp3K6CN8opRhhDbmP/3uNFck7LgFe5CU=; h=X-UI-Sender-Class:Date:To:Cc:From:Subject; b=VO8NY6o1qfC2CM0mraF4vuZSgvoWdJoqLKjcPonwW4G3xN9mhhLA7klmNPWkdcRu BuDCol+0gbX7dxft0pVjLcXbx90EUgQib0YZXNGT37h0/OTfxjzIVbVJ2BNBuJtpw VOtlqmLf+p+MwdxBDdvzlucyi5Gt9YtlRjc2eLPeT/Lor8Y3UEZBBPGjTlNdIo59k W2tuiZZ7Xl1o65QhoIgILPAW5opsS/nQtdjqoBc191VFHSIx+3YTJ7pgXWisiQn3i 81FZygEvhzTYbAktBEmnjWVcBhr7xXUy9WgjPOMde8QUoy8ouZ9jyDPDq9vLOHdCF M6N85Nt9gJt6kU7hkw== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Received: from [192.168.178.21] ([94.31.81.95]) by smtp.web.de (mrweb105 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MdfCN-1qvJfO1p33-00ZKhY; Sun, 28 Jan 2024 15:35:23 +0100 Message-ID: Date: Sun, 28 Jan 2024 15:35:19 +0100 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: linux-arm-msm@vger.kernel.org, kernel-janitors@vger.kernel.org, Arnd Bergmann , Amol Maheshwari , Greg Kroah-Hartman , Srinivas Kandagatla Content-Language: en-GB Cc: LKML , Cong Liu , Kunwu Chan From: Markus Elfring Subject: [PATCH] misc: fastrpc: Use memdup_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H U1r91xuGWx5RTDFAXYF5yRWB3ucL1v8StYFavKAxiIZjEOn9DauUovoa2uKcQ1571gcR/R7Vl 7Yp9IUgn1RUrJa95S3uz5xq+Evuat37N6AfAxv9nHJIpN6wG9d2AEzuz3EhUJ/kXnx6MnMQES VUbH3hlcJm4vjRpHcOZXRLqY7Wpj1dGPG/c0VREF0VSTS9EYNmXYkEXBhFtlq2TiWGOkXiOtR KcSBZNTSSbXksyR71YBE/Zn8M8M= From: Markus Elfring Date: Sun, 28 Jan 2024 15:17:03 +0100 Reuse existing functionality from memdup_user() instead of keeping duplicate source code. Generated by: scripts/coccinelle/api/memdup_user.cocci Signed-off-by: Markus Elfring --- drivers/misc/fastrpc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.43.0 diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index 1c6c62a7f7f5..83da6ad4e541 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1260,17 +1260,12 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, goto err; } - name = kzalloc(init.namelen, GFP_KERNEL); - if (!name) { - err = -ENOMEM; + name = memdup_user(init.name, init.namelen); + if (IS_ERR(name) { + err = PTR_ERR(name); goto err; } - if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) { - err = -EFAULT; - goto err_name; - } - if (!fl->cctx->remote_heap) { err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, &fl->cctx->remote_heap);