From patchwork Mon May 15 09:26:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Li X-Patchwork-Id: 93999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6786135vqo; Mon, 15 May 2023 02:33:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5LLq5N07rN+QjSGirYwaRH3wouQcOqInRQBPGK1hPkfEUZkOzKMXdEh2ydBNMu+bMGGgVE X-Received: by 2002:a05:6a00:2396:b0:646:6c71:ee13 with SMTP id f22-20020a056a00239600b006466c71ee13mr33087184pfc.24.1684143201732; Mon, 15 May 2023 02:33:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684143201; cv=none; d=google.com; s=arc-20160816; b=yVmPrDPiEw78CazXst+5TFFMJ05ia/ObGtHaY/9avd4f1nZWfCmjQBBlSgPz6nlkbH VGXtEp+QIlH/K3fBi8IjxAiBR8gxTjy4Rm8SeKPRfbEDhvIwxHsBi1kk1oCpFue5IPAN R5pchiISXptJgGFEcTXrtTgClK1dxl7HB9Pmdi4hd/KGtgWleS1n1wWzT5YgLD5Izj/f BMwbjatZs9lrm/vDWW3rsrvM5GkePhltyLi31swYV0qWHOwROAKy3BfmxCD8VTBIaVub 2RNNn2WV6DhB9Yvf+IVzcO3T2XDaT93V1BjSHBbRgXwxrlqcgaSxlGu0zpREEHKtnGR3 BBpA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020aa796d2000000b00648628d3104si12628632pfq.390.2023.05.15.02.33.09; Mon, 15 May 2023 02:33:21 -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 S238441AbjEOJ1a (ORCPT + 99 others); Mon, 15 May 2023 05:27:30 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765952141480858550?= X-GMAIL-MSGID: =?utf-8?q?1765952141480858550?= 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,