Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp226966pxx; Thu, 29 Oct 2020 00:38:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0rQMrOrBlWT4HchdSmr9ETbCwbD0xz0dPtbdbKWBTrpH8L18vFCOI+r6zshzU2pJvpGB3 X-Received: by 2002:a17:906:1bea:: with SMTP id t10mr2712098ejg.305.1603957124936; Thu, 29 Oct 2020 00:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603957124; cv=none; d=google.com; s=arc-20160816; b=h2lLGdFbwZFRynP6FAxbJqqs2RWAbV2PgWIjzm7AjX5QcqddmtDJVyJo9NR0MUThMs 5ojU39IbwQrwcezhjXVYvnEAUeB9jJlGCHRfU1gc2KJ+S1AmFiwsHEt79amzhpqERnh7 w/ABcSqU/Xyu5qlJcL/M0NViB9Vf1b/6kF//pohwlNcTDLq7xnvCc4r/p0sUZIudkiNM KMq+pbjVN8x81kg/Das8FNHqnA96NfiqUiHrFgHk1ZIcxUehujUiiuoXhzrFWOtY1zRb RfDdVR5TsOx48r3j6mk77byeUbT/aawKQmyxbpGsdPmzQyjiGok0Do8L90NlK9PTPc1E frdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=C3Dob6V7vi5OMNtE6HZJSY1yaPWD7j+62DYx69IGorM=; b=fUD4HdvVKdrGn/AkWlTJ39sF81UE/tr4KiMigbA2QgBFM3mEfvvgdzzYs67RMOnSBM o5KNngzsF8BuTUauR1WsGmZ/NQCjei6eAqLO7UuqDUHHDSoAsE0WUnmg2cRWxUB/YUwE UqSbMQmZgG3S+K8AC9lZX9Bw9YL9iEgfz1baSxE6RiE3YI6SbzvS/OmuV9X6Vuho0aj3 7lqtLXp0lREZFqJ5iQnPCef9vtQIKqI+uxdaGHp288bR3w2mB1l99lE7i3CpE7FARCHf fOClK+2UwTnYedEeyHqSnzFj2JIjA9CkPZNwEqbql6Ot1uqIHPljBlwWYGsChFq+StL7 Huzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e4si989438edr.585.2020.10.29.00.38.23; Thu, 29 Oct 2020 00:38:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732983AbgJ1WZq (ORCPT + 99 others); Wed, 28 Oct 2020 18:25:46 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:6984 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732968AbgJ1WZo (ORCPT ); Wed, 28 Oct 2020 18:25:44 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4CLhK8686pzhcj8; Wed, 28 Oct 2020 16:18:04 +0800 (CST) Received: from linux-lmwb.huawei.com (10.175.103.112) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Wed, 28 Oct 2020 16:17:52 +0800 From: Zou Wei To: , CC: , , Zou Wei Subject: [PATCH -next] firmware: tegra: Use memdup_user() as a cleanup Date: Wed, 28 Oct 2020 16:29:51 +0800 Message-ID: <1603873791-106258-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.103.112] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix coccicheck warning which recommends to use memdup_user(). This patch fixes the following coccicheck warning: ./drivers/firmware/tegra/bpmp-debugfs.c:335:11-18: WARNING opportunity for memdup_user Fixes: 5e37b9c137ee ("firmware: tegra: Add support for in-band debug") Reported-by: Hulk Robot Signed-off-by: Zou Wei --- drivers/firmware/tegra/bpmp-debugfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c index c1bbba9..7234136 100644 --- a/drivers/firmware/tegra/bpmp-debugfs.c +++ b/drivers/firmware/tegra/bpmp-debugfs.c @@ -332,12 +332,9 @@ static ssize_t bpmp_debug_store(struct file *file, const char __user *buf, if (!filename) return -ENOENT; - databuf = kmalloc(count, GFP_KERNEL); - if (!databuf) - return -ENOMEM; - - if (copy_from_user(databuf, buf, count)) { - err = -EFAULT; + databuf = memdup_user(buf, count); + if (IS_ERR(databuf)) { + err = PTR_ERR(databuf); goto free_ret; } -- 2.6.2