Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp33441rwi; Tue, 25 Oct 2022 19:43:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Y0vQ5JdZEsqjyqUfH7WAOBDrCLG1KrUKzB769YcDPNV/zIubSMDjNhLsFle+tOHgmpgbc X-Received: by 2002:a17:907:8a0a:b0:78d:b87d:e68a with SMTP id sc10-20020a1709078a0a00b0078db87de68amr33909709ejc.301.1666752216224; Tue, 25 Oct 2022 19:43:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666752216; cv=none; d=google.com; s=arc-20160816; b=rmy0tGpVNd/wgM7sSVWGcuyQzuGfElur1efRUEAlf8brR2MIAH0eZgHp0id3iWfGY8 US5LGTq2xcBzF8zmmO3p88glPhcAvIaOY3mkTZFAknjtqRA/jUQui96WezlymGEw+dwD gupBTF+yFBH/pAI+Ce4GPyHCHneJKpzB3zW0Slr0uHPvoLd/mTvMGHS3CIppRLgNNz4G DdKPWcu8IZr57TblHN2KjZfv8zINaljn0px1RQfkDLmR1YF5FCTYeDHEBX8/ghKYIeHY YhhAq0T4/AB2MmcJwshfGi5NaF/wDJvW+QuWYUQQHYZEm7wVtYuNVzYdynCedZ/1+uxq qaZA== 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=kp7aeD8ejtZZ72C/ddEOJcA3L7m7lkcetP61eU6N5wE=; b=i0Y7VqBfmWU7uqd9zV9B2p0l/6mVTlxI+Cipt0jenrNXGzhFNFUgJnCjksGvJPZq0p MnNtV+xiCAUnZ8Ep5Z9OrCRU74t+PVd+aZ3bOPfrFu8Sbc+51nxsvYdFmCcWVq3Vkf+y impfXBI3+So9yGioFQ56k90jZ8grHDuEmqhOm1x+M6CaXJQu2G9+nvV2f6A6bbxEhfD8 k1mvEpRtQm5aO4ojkFRsB6+deLB+tt6UJkn7GU/vVNIA97QnEW7I+eIpK6dH5xtvHpBV tBK2fY8RNyAZnBwTNHdQ/E0jANCp5yVhKxEt7OPqRhX/D40zdbuiEaP9/fV0PMh99IRl gBUQ== 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 ho12-20020a1709070e8c00b0078d3ab37efasi5233068ejc.84.2022.10.25.19.43.12; Tue, 25 Oct 2022 19:43:36 -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 S232698AbiJZCBF (ORCPT + 99 others); Tue, 25 Oct 2022 22:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232671AbiJZCBC (ORCPT ); Tue, 25 Oct 2022 22:01:02 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDC26A507 for ; Tue, 25 Oct 2022 19:00:59 -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=ay29a033018046060;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0VT500yh_1666749656; Received: from localhost(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0VT500yh_1666749656) by smtp.aliyun-inc.com; Wed, 26 Oct 2022 10:00:57 +0800 From: Yang Li To: Felix.Kuehling@amd.com, alexander.deucher@amd.com Cc: 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, Yang Li , Abaci Robot Subject: [PATCH -next] drm/amdkfd: Fix NULL pointer dereference in svm_migrate_to_ram() Date: Wed, 26 Oct 2022 10:00:54 +0800 Message-Id: <20221026020054.57114-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,SPF_HELO_NONE,SPF_PASS, 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/gpu/drm/amd/amdkfd/kfd_migrate.c:985:58-62: ERROR: p is NULL but dereferenced. Link: https://bugzilla.openanolis.cn/show_bug.cgi?id=2549 Reported-by: Abaci Robot Signed-off-by: Yang Li --- change in v2: According to Felix's suggestion, move the pr_debug up before the kfd_unref_process call. drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c index 20d6b2578927..b9c8d29d95aa 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c @@ -978,12 +978,10 @@ static vm_fault_t svm_migrate_to_ram(struct vm_fault *vmf) out_unlock_svms: mutex_unlock(&p->svms.lock); out_unref_process: + pr_debug("CPU fault svms 0x%p address 0x%lx done\n", &p->svms, addr); kfd_unref_process(p); out_mmput: mmput(mm); - - pr_debug("CPU fault svms 0x%p address 0x%lx done\n", &p->svms, addr); - return r ? VM_FAULT_SIGBUS : 0; } -- 2.20.1.7.g153144c