Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8991681rwi; Tue, 25 Oct 2022 13:39:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4Czrz9DLjpq2+Mfd7iKZvTxr+B27fQYdeeM2j5oOjiurI9MroFH2vSdfcGsukDAKzEoni3 X-Received: by 2002:a17:906:9752:b0:78d:d2e1:d745 with SMTP id o18-20020a170906975200b0078dd2e1d745mr33649133ejy.452.1666730378499; Tue, 25 Oct 2022 13:39:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666730378; cv=pass; d=google.com; s=arc-20160816; b=InIf7CdWRAv2x/o+By0gGl/q0b1ngrLM5JEyuD+d9eeounwSPCGkyvGrmKPET0C27M lCeTn4BBOpUVbgPnt73L5T0ijyKjd6YKHpuE4DZqXlREIsdb2C86DKgDghy8cdEMHCFx U2dUfh9OhTF//RjV5rlUor4U+tvuCkIsuHTJbbeDji9My1dGFPvoeEh3EayfYvj/5FEl UtJwQ7nmLiBFCmhTpZ90n+HhjvsIHyW90H9pP9jEjMEcA1mC4sr6ejpc9ZPIHeNNTvKI uh6Gj138hVqUDnN488wba56jB3YxInS1gB9mBWTHX+dbe/GuooOjOatGflIBaA6rjpGV yzGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:date:message-id:dkim-signature; bh=yRV5HvcJZRyQGQvM+lhAaxHGbLXkP0NOOm1IIX7S0sQ=; b=Xug2JzmVznuTYuSbaS6aa9l7+0+5lc2FRtK5fkUt+6Gn3d3pq1feEV4H/P1bBfJ1oZ thFje/3I94kv18ec3H8tyBWqPeLNh4bDIF3jonS9/l+P1eJ0D0CCjfTpWCqjmYJ5mhsb FZKC3ARkeztfeVoxScuG1aC5CbGxsO5m/9EzUFmwyetNTcWR/wTkZyUwnXZT3Qwpa4h3 egdT9esdB9Nx8Itmk1QSujmzN5MRkyOeuwjFQmuYFLk9/vpF/EKQeEKvFflpGZFoKYRv HuxwY5F0okV0VwvPBPf5f7Vek1tQxYykKUkLO9GBCAqQFKBKDI9JiGTqoQ8nf5XUniCi YwiQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="CBg/eROx"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q17-20020a056402519100b004574aae3f47si63433edd.509.2022.10.25.13.39.13; Tue, 25 Oct 2022 13:39:38 -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; dkim=pass header.i=@amd.com header.s=selector1 header.b="CBg/eROx"; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232114AbiJYTjq (ORCPT + 99 others); Tue, 25 Oct 2022 15:39:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbiJYTjo (ORCPT ); Tue, 25 Oct 2022 15:39:44 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2069.outbound.protection.outlook.com [40.107.244.69]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54452BE39 for ; Tue, 25 Oct 2022 12:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaIg+soDo8T5eqXRIObqW6HWG0f9VZCbgbcmA6PPn2v/XKOWfeYrUZC0bWtp9GEXiv/0uiLKEsX28Ho2pb6laOT7H5VuSMSzRNZ19ib7KrKoqHwOSXdHh1DouJOPIoEAJyALA2NUCLMNSuaxBMuH904aud8n7Hse2+O1Z672/JebmBUbXtm/TAbfmQAhLB1SUeWuywkhlr/s/BdB5gS3mXbXJQLZ6nZ5DsK9lOYsVgtWqTmZmwpG4THTwDzNNm2h6JLUJ9T2ipnIUQUSD3EemGSb9VIhBHJTrz9nDdty6SvDW/0Wy51rMrURasraNw6/UcmCpuzgv7rEkAVdakSOXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=yRV5HvcJZRyQGQvM+lhAaxHGbLXkP0NOOm1IIX7S0sQ=; b=WuaafR2MvEloBAjjD8Iq3RPAYqXtlj2FGNrVzabZF8Js1DJ8QTplXUsr0QR9sUo8ZWqbJlCZPcoqB6Fl695wYA4sHGc5kwMeOSduR/I1ATc7dQ40q6GqlDtz18fZXBZqc39Fjow2mO2SLq/N0Aw8KtazlatfYSyrc0oNVlLyYpF5urAhQyXZ4qY+YXOlxxLc5RZE7cIyzZgzkaXOWCUYAvLtguup5V6XYKV3uR/9zWEB5K8XsqEK1XJ0ZuYQvIiOPiJV3IUKb/UOK8N9dRoz917d5PxsLO7R1sM7L+RQMqERDiWCsBGTxHfy3WpIPFh7diJN3Kwos7wUFI/nTZ24ZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yRV5HvcJZRyQGQvM+lhAaxHGbLXkP0NOOm1IIX7S0sQ=; b=CBg/eROxE8AmDviuINdUOHxKpE1+npngIEcBOWe6XzJY0vKPcJLomWNXD5Ued9umksHZ7nizLCO31tRIGKw90J3HpCt/fPYptHTlH01sPo//u1DEUeLnReT7heOL/nSSGcmPt7qKeIdRUYNj/SYpyFeh7Mkb9/0jMikiGTBIf3I= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) by DM4PR12MB6326.namprd12.prod.outlook.com (2603:10b6:8:a3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Tue, 25 Oct 2022 19:39:40 +0000 Received: from BN9PR12MB5115.namprd12.prod.outlook.com ([fe80::7e91:f457:9ec5:33be]) by BN9PR12MB5115.namprd12.prod.outlook.com ([fe80::7e91:f457:9ec5:33be%6]) with mapi id 15.20.5746.026; Tue, 25 Oct 2022 19:39:40 +0000 Message-ID: <9c58cacc-27a5-035e-0c17-2a0e8b30cf54@amd.com> Date: Tue, 25 Oct 2022 15:39:38 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH -next] drm/amdkfd: Fix NULL pointer dereference in svm_migrate_to_ram() Content-Language: en-US To: Yang Li , 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, Abaci Robot References: <20221025072822.129940-1-yang.lee@linux.alibaba.com> From: Felix Kuehling In-Reply-To: <20221025072822.129940-1-yang.lee@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: YT1PR01CA0039.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:2e::8) To BN9PR12MB5115.namprd12.prod.outlook.com (2603:10b6:408:118::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN9PR12MB5115:EE_|DM4PR12MB6326:EE_ X-MS-Office365-Filtering-Correlation-Id: ed49cb40-abeb-49e7-f0ec-08dab6c0a889 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iFPe0MCXwSjy0FHfYePwkpKdP0O0hgK+elO195EYB2nzD4WGX0p98RORfDeSSKIrYG3oRjE2EZfJl6NFgFFfNa6PNCIk67NMdBReTVHgDAuNVoFGKAsHHQdALR70ydPlHZRXYTLyOGrsPnp7pyQct+o7cQJIqwPgORBxkVAXNzBKkcXNpArIAkQC7jCiv5c7GOa6kH7T1NeGEt/pCtGtnExL+sFhDQdpgjLD242VvBEILuWTT9n0e+JiLHwOUQJSk38eXUOrYDFeDrz4kr/P1X2hFAVB1CNpM1t58IMD/+Ld2G+A+Dw5WuxtrplZfAlR9QaJVxef+88JrrhVoVYk+vA3/ddLfH+1pXYUEmecIBsBFcowyGNsjBQEHNRvrhh7GyeC48ix0Go8cUy8E176PkSQFIXIZd8+E1ebHxflES+vAhO+wSjc+GQbVIbVt61f72mXm/Hk5dPErmbKScF5rij44LLEk+rGM5r06EDzBGuT9ixE3Kz8kmPl1za1Tn2i6sBRuNohLS4y7C2Xcm1cMbvnjJdbtDwf2biUd5DPMOkOEYPQelC7HE1pZRWOnOD5Ra4MLRyHL4YgkxCnmO+OxNcj5fN2yGM8kZOImpS8fvpdxgpG/SEKA+f9T6k3lgtyyqnep5AUJAHNv80216TNaQ4pDNzhyp6IuxdKGSuNR/4elfFyFTHmKjOWKT81uFpGLnd6oedhm1IfJukvZ/SsU0akAqDI0VoXbVgNKZmxqLLC4VgLvCpI0gT5lXyJvuNY76aJOXUkm1PagRXu6AbIl2dI5ab4RD1+CYCmD3pcHIX2Kk0azHU7XwZJeVNhPk/0mi+tZn4lDnkQAcuIpsjQRQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN9PR12MB5115.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(39860400002)(366004)(396003)(136003)(451199015)(31686004)(36756003)(66476007)(66556008)(66946007)(5660300002)(38100700002)(8936002)(83380400001)(86362001)(31696002)(6636002)(316002)(26005)(186003)(2616005)(6512007)(6486002)(478600001)(966005)(4001150100001)(2906002)(8676002)(44832011)(41300700001)(4326008)(6506007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d1VCN0xNUTQya1NHdk5kSk8vZjUrZ3N2TzZQWDVpN2tEVkJMMjgwSGpiSXBL?= =?utf-8?B?OWE5Rm9uWlZsbEQ2bnpqNHhpdkJyU2dGc24xNUJhb3I4UGRxNXBwWXdzL3NJ?= =?utf-8?B?ZjJSazJET0swcjZDdGwySEl4YndiYnV5K3N1L0V0d3Q5Y2xCajNRM2Y1UWVq?= =?utf-8?B?dzViUElLNXJham5FZ2VnTm9wTW5jc3o4SmE0UmFNQzU2Wk5QbHYxUC9Xc1Bm?= =?utf-8?B?T1BpcS83VjArMHN5U1dxV0ZVME0vVVpISzlDdzJpZzBUUURxeGJuTmdoK3Az?= =?utf-8?B?K0hQQmhTanI5NnV1QjFYQm82Vk5zOVA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1ljWEhwNy8vZGtH?= =?utf-8?Q?RrpqdKqUw1/Hlcp88shsjJTjp?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed49cb40-abeb-49e7-f0ec-08dab6c0a889 X-MS-Exchange-CrossTenant-AuthSource: BN9PR12MB5115.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 19:39:40.5809 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qk34KpTOuIwqEkUlLRMXG5pr5FBwplVS3XlNEeBop+umed1lWfWVKMrYewYTRUpBJYChvnDdchotK7a7dG3drQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6326 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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 Am 2022-10-25 um 03:28 schrieb Yang Li: > ./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 > --- > drivers/gpu/drm/amd/amdkfd/kfd_migrate.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c > index cddf259875c0..405dd51521dc 100644 > --- a/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c > +++ b/drivers/gpu/drm/amd/amdkfd/kfd_migrate.c > @@ -981,7 +981,8 @@ static vm_fault_t svm_migrate_to_ram(struct vm_fault *vmf) > out_mmput: > mmput(mm); > > - pr_debug("CPU fault svms 0x%p address 0x%lx done\n", &p->svms, addr); > + if (p) > + pr_debug("CPU fault svms 0x%p address 0x%lx done\n", &p->svms, addr); Thank you for catching and reporting this problem. I think the correct solution would be to move the pr_debug up before the kfd_unref_process call. That way you're sure that the pointer is initialized and that it represents a valid reference to the kfd_process structure. Regards,   Felix > > return r ? VM_FAULT_SIGBUS : 0; > }