From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2232C43462 for ; Thu, 1 Apr 2021 09:20:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D7EB610CF for ; Thu, 1 Apr 2021 09:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233327AbhDAJUU (ORCPT ); Thu, 1 Apr 2021 05:20:20 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:15844 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233616AbhDAJUN (ORCPT ); Thu, 1 Apr 2021 05:20:13 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4F9yJr6SQ4z9s0x; Thu, 1 Apr 2021 17:18:04 +0800 (CST) Received: from [10.174.178.174] (10.174.178.174) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Thu, 1 Apr 2021 17:20:07 +0800 Subject: Re: [PATCH -next v2] staging: greybus: camera: Switch to memdup_user_nul() To: Dan Carpenter CC: , , , , References: <20210401031752.2861248-1-yangyingliang@huawei.com> <20210401074332.GO2065@kadam> <20210401074719.GP2065@kadam> From: Yang Yingliang Message-ID: Date: Thu, 1 Apr 2021 17:20:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20210401074719.GP2065@kadam> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.178.174] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/1 15:47, Dan Carpenter wrote: > On Thu, Apr 01, 2021 at 10:43:32AM +0300, Dan Carpenter wrote: >> On Thu, Apr 01, 2021 at 11:17:52AM +0800, Yang Yingliang wrote: >>> Use memdup_user_nul() helper instead of open-coding to >>> simplify the code. >>> >>> Reported-by: Hulk Robot >>> Signed-off-by: Yang Yingliang >>> --- >>> drivers/staging/greybus/camera.c | 13 +++---------- >>> 1 file changed, 3 insertions(+), 10 deletions(-) >>> >>> diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c >>> index b570e13394ac..2ecdc1bc5092 100644 >>> --- a/drivers/staging/greybus/camera.c >>> +++ b/drivers/staging/greybus/camera.c >>> @@ -1120,16 +1120,9 @@ static ssize_t gb_camera_debugfs_write(struct file *file, >>> if (len > 1024) >>> return -EINVAL; >>> >>> - kbuf = kmalloc(len + 1, GFP_KERNEL); >>> - if (!kbuf) >>> - return -ENOMEM; >>> - >>> - if (copy_from_user(kbuf, buf, len)) { >>> - ret = -EFAULT; >>> - goto done; >>> - } >>> - >>> - kbuf[len] = '\0'; >>> + kbuf = memdup_user_nul(buf, len); >>> + if (IS_ERR(kbuf)) >>> + return PTR_ERR(kbuf);; >> ^^ >> There is an extra semi-colon here. Checkpatch actually catches this >> sort of typo. > So when someone makes a typo like this, my response is: > > 1) Let's add this to checkpatch (turns out it was already done) > 2) Let's grep the kernel and fix the other instances. The command would > be something like: git grep ';;$' | grep '\.c:' I search it in kernel and find some other instances like this, I can send some patches to fix these. Thanks, Yang > > regards, > dan carpenter > > .