Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1703240rwd; Fri, 9 Jun 2023 00:30:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7fC0Kuck2XOSGkfqrepKjOnr1b+f9yf3Yc5NwWLhgrDsOQkYbDkjGYpzJ2uk0Q7ngTkn4n X-Received: by 2002:a17:903:1207:b0:1b0:ec0:7d01 with SMTP id l7-20020a170903120700b001b00ec07d01mr419872plh.35.1686295851274; Fri, 09 Jun 2023 00:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686295851; cv=none; d=google.com; s=arc-20160816; b=xSGLAO+numiYeCUIL+J8ONdIOacHjBcc2uzpEPYVTeOwlZ13cJHSJwiLWZluhFYsty clcVzJXCBpia5enU3qlu3v+LxQyK+oUaqOQMCa6xgiLZ4BoQGQG7Of3IeE9P5E7OslUu N5c/yvkWO0IIhMEYiJWUHOaZPjgjOsDnftaSfcl8bgkT7QoYuStQJIThQp6Ug27vLP8d eiABFCIF+LHBg+0V9Wh52JYxeRZw2lkD3j1Md1qJQh1clX5HmzydTaMzlYMToQARsYV0 N/a/OOwgYnV4oWBBsvULxYCNEiHhVfuoHoS7OYCxfFtjg9X9ImIup5gwGhyUyuR8l0bq bDUg== 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=Q59tXNFuirIQoOXubYjpKWHe1UjiWVgEBpjnaIusIOg=; b=eSNkNLc268BdihrUa+Hx9zAIYhcRWP0BoYYA82ppJGX8kBUG9L1/KJvbymSDkYDNyI duMCR+kobGA/sh/Cti3KaUari6hspNXmiKh+d8/B2L3Z1LwS6eOzHIa2aZto4yw8dGw8 Z9q38st7BNM7OJovHJ+r26Q3VyVa/eyMkOYy7GLMDUKOycLeDAc76hoij33MzrhyS0qS rF8urbPBG2vFTVxAhlmymWO5/JvI6etjPuT8B5P5DzRDT9NK9whQJj/LAqwhCLka413V ifKzGuY97HQ7QUmw+lfcciZ+UbTB2+F29gB8YprbuvCjiNfMHx0NME/42OlfuUEw2d4G 2voA== 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 f12-20020a170902ce8c00b001b382b2d2fdsi848439plg.144.2023.06.09.00.30.37; Fri, 09 Jun 2023 00:30:51 -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 S238207AbjFIHPt (ORCPT + 99 others); Fri, 9 Jun 2023 03:15:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238580AbjFIHPe (ORCPT ); Fri, 9 Jun 2023 03:15:34 -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 4EA193A99 for ; Fri, 9 Jun 2023 00:15:10 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=jiapeng.chong@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0Vkh8XKe_1686294896; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0Vkh8XKe_1686294896) by smtp.aliyun-inc.com; Fri, 09 Jun 2023 15:15:07 +0800 From: Jiapeng Chong To: jens.wiklander@linaro.org Cc: sumit.garg@linaro.org, op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] tee: optee: Use kmemdup() to replace kmalloc + memcpy Date: Fri, 9 Jun 2023 15:14:55 +0800 Message-Id: <20230609071455.120995-1-jiapeng.chong@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,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,URIBL_BLOCKED, 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 ./drivers/tee/optee/smc_abi.c:1542:12-19: WARNING opportunity for kmemdup. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5480 Signed-off-by: Jiapeng Chong --- drivers/tee/optee/smc_abi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c index 3861ae06d902..d5b28fd35d66 100644 --- a/drivers/tee/optee/smc_abi.c +++ b/drivers/tee/optee/smc_abi.c @@ -1541,12 +1541,11 @@ static int optee_load_fw(struct platform_device *pdev, * This uses the GFP_DMA flag to ensure we are allocated memory in the * 32-bit space since TF-A cannot map memory beyond the 32-bit boundary. */ - data_buf = kmalloc(fw->size, GFP_KERNEL | GFP_DMA); + data_buf = kmemdup(fw->data, fw->size, GFP_KERNEL | GFP_DMA); if (!data_buf) { rc = -ENOMEM; goto fw_err; } - memcpy(data_buf, fw->data, fw->size); data_pa = virt_to_phys(data_buf); reg_pair_from_64(&data_pa_high, &data_pa_low, data_pa); reg_pair_from_64(&data_size_high, &data_size_low, data_size); -- 2.20.1.7.g153144c