Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1755992rwd; Mon, 15 May 2023 02:33:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7NptvlUyjiGG14fys9No/Lkaekk3Zau5gQfp0NDhv4MiH8kn6RXkplpOJmUEnjALPvwY7D X-Received: by 2002:a17:902:cec3:b0:1ad:e099:fbf9 with SMTP id d3-20020a170902cec300b001ade099fbf9mr15712521plg.42.1684143222181; Mon, 15 May 2023 02:33:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684143222; cv=none; d=google.com; s=arc-20160816; b=t1VVk4SrpXo5vqfBUuBYjnGhrXZRwjZekbyN1DEzUGGbTuRC+QqZOcF4hWHZRQaLLC dQ2dGz6rB/uM+WROiOCvxxIERrNB00wCbEu5IDjtZ0jez8qYqXGryunfWP8GI9phdtJi v1Htrm6kd9Zl7FzIqIuuCEPTozASp67CpXjkCrjDbXuMfa/lAn6HCHTT8dB9NeR1kY6s 2hnBniMMTs8+sk/6VlCC8/7/upa9Z90Cn66gS3K/w59bcSNNHg/64uD7lPbssSQHjLxG LnDPQ8yvXTh8n5/fYyPmUc5qXhB7WqEXDrBCe6p3P1IrNIsx//UWFcNqfYjbXu5qc03M zj1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=HVKQymt3S5fOtqiF+2z3P458koEAM92SxsKp5KTKmhY=; b=ltKc9SNmQDi0Xwoq3E9HbNTrXfCqdwQDs2zjQSBHkOfr6MeL/eFCRweVv3ufS3zNUk e+QL1Nn+JLyGDndcIt5LCa5nWk7wf7dpR5oi2vXUWdidRdkHCGdBB2nOGmi/ZSmer/UH 2gohlz344kHT1o3Hc5/cxL7yyma6LdZF14apoWTSJZW5MQCRGIK7T3eruekI1mBB5KOK ehQtrDV427aI3bAMETT2Tp/ukzWx4scHB4msuWizc+fQ5dIdGdKBCzfRgm6me1kjEg94 p67HESdMcqQdrLgVuM6HUc2oTvMcTQBfCVqBzUnWgM9ymlLq3g6W0vrju3oMcWSuo9wD U4Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y22-20020a170902b49600b001ae1ecff247si1736605plr.492.2023.05.15.02.33.29; Mon, 15 May 2023 02:33:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238273AbjEOJ13 (ORCPT + 99 others); Mon, 15 May 2023 05:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238806AbjEOJ1C (ORCPT ); Mon, 15 May 2023 05:27:02 -0400 Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com [115.124.30.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DDFA1730; Mon, 15 May 2023 02:26:09 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R191e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0VigIxMm_1684142765; Received: from localhost(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0VigIxMm_1684142765) by smtp.aliyun-inc.com; Mon, 15 May 2023 17:26:06 +0800 From: Yang Li To: srinivas.kandagatla@linaro.org Cc: amahesh@qti.qualcomm.com, arnd@arndb.de, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Yang Li , Abaci Robot Subject: [PATCH -next] fastrpc: Use memdup_user instead of kmalloc/copy_from_user Date: Mon, 15 May 2023 17:26:04 +0800 Message-Id: <20230515092604.79990-1-yang.lee@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use memdup_user rather than duplicating its implementation, which makes code simple and easy to understand, and silence the following warning: ./drivers/misc/fastrpc.c:1259:8-15: WARNING opportunity for memdup_user Reported-by: Abaci Robot Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=4949 Signed-off-by: Yang Li --- drivers/misc/fastrpc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c index f60bbf99485c..a897dab13c61 100644 --- a/drivers/misc/fastrpc.c +++ b/drivers/misc/fastrpc.c @@ -1256,16 +1256,9 @@ static int fastrpc_init_create_static_process(struct fastrpc_user *fl, goto err; } - name = kzalloc(init.namelen, GFP_KERNEL); - if (!name) { - err = -ENOMEM; - goto err; - } - - if (copy_from_user(name, (void __user *)(uintptr_t)init.name, init.namelen)) { - err = -EFAULT; - goto err_name; - } + name = memdup_user((void __user *)(uintptr_t)init.name, init.namelen); + if (IS_ERR(name)) + return PTR_ERR(name); if (!fl->cctx->remote_heap) { err = fastrpc_remote_heap_alloc(fl, fl->sctx->dev, init.memlen, -- 2.20.1.7.g153144c