Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2065766rwd; Tue, 13 Jun 2023 19:36:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7EwfNVp9O5UdjkHF855nfI2yZkuGp08ft41ncaJEENi3WJ3DHIDD/5YcVD9BfHGtIvy3h9 X-Received: by 2002:a05:6808:1281:b0:39a:ba14:3140 with SMTP id a1-20020a056808128100b0039aba143140mr11663106oiw.25.1686710166156; Tue, 13 Jun 2023 19:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686710166; cv=none; d=google.com; s=arc-20160816; b=c2SKPZbq+/cJhKLsyJ3hFr9AVL7OBST6gL8EE7OHKw0iNoEUWLF9Y5ScF78J0/7U3Z uFVV6ZGIPp229EwO38tk6F9/Gk04pQuSwiOKSMQCq480XZffat+HrNidwcVZOk2AJZkE v358JpP2/nU5GDGzT4vgiYxLM+enbf+ZkJqsVVUT3amQNrb00pF2QZMjPZvIYwMZnr4C hk1mNdPU97DHwxO/eC50VJOVc0AOv2kLrVaf8ev+RqcLY03V7x6sGpNxD2ARYGqcEdUs f68hPeNgR3PoNwDQiZRUpAeAQrVW/z7VzjGhTwB9U3w6VG71nXohAftbr22CgjzqkBfh wg6g== 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=tj94+ivbYSCcxOu+ADZSXuVSlqo1xocobMLAmowf9oI=; b=KdzJB4upkULFs+n0IhkjpW5Oni7+cKEre80i0PWSBoU7btD88TI0Ry1EbI0FJ7lUqn CcNXpiC04gWfv02E6pZYv5fz1iV4YzrHuztLhpcYWRMhWAGqOq9aN0SC7mByYmTIB8ay /9Zfb4WHaweT1JHDCvFykcEvlDMsMv/9QW8BsFpWfZSdhXIenVnTMfU0+JxQe8Ft+AQl Hr9g7yjRm585yEBEO+xr8Kj1rQBxT59vm1oQ7YjbPeioWKooJclg3+DneL+Y5Of9MS2Z uOVzkzW9kH/wXXTtXCt2P2SX1hhzvpEo5zlofPP0TFrpI0L6vN/Xlj0fExsOY5DyR1rt /a8Q== 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 lb3-20020a17090b4a4300b002586dbee167si10311647pjb.170.2023.06.13.19.35.53; Tue, 13 Jun 2023 19:36:06 -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 S241954AbjFNCE7 (ORCPT + 99 others); Tue, 13 Jun 2023 22:04:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242109AbjFNCEp (ORCPT ); Tue, 13 Jun 2023 22:04:45 -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 9D77A1996 for ; Tue, 13 Jun 2023 19:04:43 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;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=11;SR=0;TI=SMTPD_---0Vl4KJRo_1686708273; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0Vl4KJRo_1686708273) by smtp.aliyun-inc.com; Wed, 14 Jun 2023 10:04:40 +0800 From: Jiapeng Chong To: Felix.Kuehling@amd.com Cc: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] drm/amdkfd: Switch over to memdup_user() Date: Wed, 14 Jun 2023 10:04:32 +0800 Message-Id: <20230614020432.44044-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 Use memdup_user() rather than duplicating its implementation. This is a little bit restricted to reduce false positives. ./drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c:2813:13-20: WARNING opportunity for memdup_user. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=5523 Signed-off-by: Jiapeng Chong --- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index d6b15493fffd..637962d4083c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -2810,12 +2810,9 @@ static uint32_t *get_queue_ids(uint32_t num_queues, uint32_t *usr_queue_id_array if (!usr_queue_id_array) return NULL; - queue_ids = kzalloc(array_size, GFP_KERNEL); - if (!queue_ids) - return ERR_PTR(-ENOMEM); - - if (copy_from_user(queue_ids, usr_queue_id_array, array_size)) - return ERR_PTR(-EFAULT); + queue_ids = memdup_user(usr_queue_id_array, array_size); + if (IS_ERR(queue_ids)) + return PTR_ERR(queue_ids); return queue_ids; } -- 2.20.1.7.g153144c