From patchwork Wed Apr 22 02:58:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zou Wei X-Patchwork-Id: 11502763 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A26C0159A for ; Wed, 22 Apr 2020 02:52:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 808B3206D5 for ; Wed, 22 Apr 2020 02:52:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tfY0/khT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 808B3206D5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zDZWGPFHgCdxGi4+UUpFQq2AWWwXKnjlTg6Iho89XhQ=; b=tfY0/khT0HwD5R 6adaSb9fY15qDvNcIXPmcJtjM4rnxzkmlb0u0UJ5zGOXc6Ii4jJObp+LEIheQ3iAC8p64W+EX9blu Z6Z4wBUCvDQ8UUd63k+Wif123l7eEtMdo6/1E6sQJtPQ+9gUewS9fjVxifk9xjzpVK77lrCQnJX+D Y0W+eBOqI+r6z0CXaGtwkWaVl2Z8BuC6b2EwsujuhHL6MHzAnpQBxEbrVwnilH3Y4aoGD2+E2IFY9 D0vKgQlDateqUZs+bZs9g+6BLGNu/AEdxeNPaNmN91wwER+sJ3nGtM7Ob0iD9pIqoxDfm7ZQM27ZW ZuaeildRnHBLZYUPmAuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jR5VO-0004Ua-E2; Wed, 22 Apr 2020 02:52:54 +0000 Received: from szxga07-in.huawei.com ([45.249.212.35] helo=huawei.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jR5VK-0004TK-J0 for linux-arm-kernel@lists.infradead.org; Wed, 22 Apr 2020 02:52:52 +0000 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 99E05367F653A2B1F84D; Wed, 22 Apr 2020 10:52:42 +0800 (CST) Received: from linux-lmwb.huawei.com (10.175.103.112) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Wed, 22 Apr 2020 10:52:36 +0800 From: Zou Wei To: , , , , Subject: [PATCH -next] misc: xilinx_sdfec: Use memdup_user() as a cleanup Date: Wed, 22 Apr 2020 10:58:50 +0800 Message-ID: <1587524330-119776-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 X-Originating-IP: [10.175.103.112] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200421_195250_803605_3B0C3A17 X-CRM114-Status: GOOD ( 10.57 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/, medium trust [45.249.212.35 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zou Wei , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Fix coccicheck warning which recommends to use memdup_user(). This patch fixes the following coccicheck warnings: drivers/misc/xilinx_sdfec.c:652:8-15: WARNING opportunity for memdup_user Fixes: 20ec628e8007 ("misc: xilinx_sdfec: Add ability to configure LDPC") Reported-by: Hulk Robot Signed-off-by: Zou Wei Acked-by: Dragan Cvetic --- 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 71bbaa5..7a75894 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;