Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2052607rwb; Fri, 11 Nov 2022 04:30:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4rXeT0mp9ZxRbwGsI8+o90ivk/9GnoV3g/AVMqbAc3ij4rAgFuF7T7ExYSYKqDPrKHASy/ X-Received: by 2002:a50:9503:0:b0:457:1edb:996c with SMTP id u3-20020a509503000000b004571edb996cmr1221050eda.363.1668169848876; Fri, 11 Nov 2022 04:30:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668169848; cv=pass; d=google.com; s=arc-20160816; b=WexMjcu5bq8ppcToOPAuMaV8TAOiu25j0elHo9MaVc1NZ7HNVVIQYhOtFL8qTt+Eg+ OOBKolGRc1OjdDUJePRJjyRyyZ/d+zzZKIqnwNwrRRNL79WE9gSlL4ngr45UQTcSlst+ Ssdt1LJEPgtWFfJ/S5bBPACwX4l8FAjr/ec3EBnAe7icgtlVOBQ7Qaci8Z1AGopP7Asx IzHqlz+Gr0fSlggpDKEbBY/ZclKJaAw6XffN1J0d4VeyEjKsF4Br8kLH2yfPrcM+lpGC Y+0kErO54sRhn0CzxRnotY5LLc5Tqwx9g7G2uXrClXRbbxhk3NawHn3FARoZsV443GA7 YtOQ== 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=kpxmUgpxfK42BNijRIx00abU9v3g7X+iyfuDoOpTkTA=; b=xB6eDFSvEfy4Ae7aPF4L5b9FPD2aio68g144wSZvOdnVslSc9XW7qYPimB7J7+hQra hicyUDC5Z1P0KAX9eakuRFczakkNFJYWk2cLFsvbXBG1U8c/IOdBnWZzToyucTVEZoAm kumpcNDdHhDlYoCCY70DqVtTkp/jXGIAdbNUY7HSECzf0QaE93Q3GHEtJ/79ZqtAA7IM Lu8s7hCrx6ZGmfxV05OD4gBHNz8yPDk1tRG2ox5cJ3qLs12H+dZUJIYN3FkGxkEkBndp 7yXuKXlwQicW3NpemI7UXPr5b71AFXcnkFT2ImUwyo5+qTqRgqmGwGcjGWsyqZT3xGpk +dKA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=JjXl2giI; 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 dn17-20020a17090794d100b00797670441desi1851816ejc.911.2022.11.11.04.30.25; Fri, 11 Nov 2022 04:30:48 -0800 (PST) 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=JjXl2giI; 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 S233673AbiKKL5n (ORCPT + 93 others); Fri, 11 Nov 2022 06:57:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233563AbiKKL5b (ORCPT ); Fri, 11 Nov 2022 06:57:31 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2086.outbound.protection.outlook.com [40.107.223.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A3167F55C for ; Fri, 11 Nov 2022 03:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A4PJAeKUMdZLkLkLpav75txfM15swF3nC+hY34s22UBtv2HPLdQZlTLDI/WA3NL2WN0wFNPohA2qf2SF1mVX7LH0haAU5jtOACara/gg/YVWrVKyHEJ4By+DrV1TY6mPlsnitThfZ4uByINaZV+Ww+BkSc/V+o22Q4++hrK0zzuKz6Yeq8mNEuKKpTrPkEWAlX1iclajgASpXLPTKO05ZC5nzoaYkoTXD9kmnuQ4dx22tcCY5nXpn1uTB0LuVyXOGyBzO+UwzZJodSJR19ekAtWRdnvbQxcHTdMaQYUu9Jsv/B+XCYPPKx+ihdbn4YCCHCjYrw/xmIIpl4eAXLaSqA== 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=kpxmUgpxfK42BNijRIx00abU9v3g7X+iyfuDoOpTkTA=; b=DjQ0l1XUOSECJbyjudk8Wx5W+Rt4cYggBzYumWIubcGWrvQAcdoheSpeGerG4vth9xw1OygjWCJN8r8lboMzAu7d0uci8r1x9RGkETPyO77aSUnZ3tJnHtdFb4Dyph5ANh0Ym7FJx3l1AjaDBnqNgpaQrRV8Eymu6v0ZKUdlWK3s+6VemgrwUDiPFEXdtuf76BkEIVztUxIHWYYDmOLS3Ps7vjf/M+LJt2dXnL480cL/Hwrb+PJW7l8eoH/7RiHyZQdcAIyoPjn8qAZu8ttZ6hOA41xS/OebOHHjR2h8g/5IQ6TO0n7Ld0/89Bh9P8ox6FA00b69SDzEA5WQ/btFQg== 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=kpxmUgpxfK42BNijRIx00abU9v3g7X+iyfuDoOpTkTA=; b=JjXl2giIZUbO4xHu2/IE0XwcINHqam1j5+OwVMkI6urkoqyVJWcz3O26qOOQkQQujj0os8scUzWPdSFNxUlpFUR7gkHrfLJHxJX4jvDsmDmqytKSd37aY37+x+/NHIXMSPMhdCHoOKvnzGEM9velJXl0UbCKXfBFjWntZ7478Ro= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) by LV2PR12MB5920.namprd12.prod.outlook.com (2603:10b6:408:172::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Fri, 11 Nov 2022 11:57:28 +0000 Received: from BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::7d43:3f30:4caf:7421]) by BN8PR12MB3587.namprd12.prod.outlook.com ([fe80::7d43:3f30:4caf:7421%7]) with mapi id 15.20.5813.013; Fri, 11 Nov 2022 11:57:27 +0000 Message-ID: <22a00fd8-2489-d803-bea4-e624c355a984@amd.com> Date: Fri, 11 Nov 2022 12:57:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] drm/amdgpu: Fix memory leak in amdgpu_cs_pass1 Content-Language: en-US To: Dong Chenchen , airlied@gmail.com, daniel@ffwll.ch Cc: alexander.deucher@amd.com, Xinhui.Pan@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, yuehaibing@huawei.com References: <20221110143314.708434-1-dongchenchen2@huawei.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= In-Reply-To: <20221110143314.708434-1-dongchenchen2@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: FR3P281CA0145.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::8) To BN8PR12MB3587.namprd12.prod.outlook.com (2603:10b6:408:43::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8PR12MB3587:EE_|LV2PR12MB5920:EE_ X-MS-Office365-Filtering-Correlation-Id: 4915db9c-72bf-4886-8000-08dac3dbe796 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ecR2GgbwuoC8QvqOEwsjCWd47Z1yrPL2gSeFGmMQjeJpNrV0kipUn7ibR3lU1iGr4kZlGkfBz/LU1qhnWhuEP0PTuQqCEcrjA3PvptfdX2tXiGqwEd8714rpCpMeMUfi5YXPJci6NcW+hucsDhJ/QWhodmX0LD9AI9KVp43N702dsjiY6RMRx71pjOoidRkaVwdmnLnF8k/TsuPUb088PkCFeQ179hlCqWS+NI5QV9zUjwevMJar8k14+L3FFUQM1O9MNanbE4t1a4OjGMPpxTipAyexTVxg1HZ7lwsTGnRzJimdTJsFErIwUkW0Td6zmbNkruMUMfQzM+9lGvkqXap9CkEN1RNHVYmDCDfPWZWrQNte1QDcDueda3SS3cz+gXIVEZ/ub4JpRqLzJKPU7AfuADhP4TYpWDOQzMqi2p0zD/S3qIdI0H7pnLrpL5tZFzISfFg9V2NTpsK9smecvM9MPoisvEJNFeoFdsQ2Qi0YKxHpbqLsRtlFxSjSIO3RVyXBLNCRCc0odqJdEt7DP7/fWuog8Q8H3TXspQH54vlVZcx/3p7uLR8FKVSGKR0KLI3bNbi4/gWgqzp5gE6xqHQtGVQoy9zyO+3ujsE/Ccjnn1IzAgaMbDpL/Ty+MfbdIhpnbAPn+LS3G7xnwVPTBnmWWi3rkvBYrqMy6zediA9wH2+Fh5MUy7AJluHBD04lCktfgEOToaut0koDWaDLpHeTqj7/E+1B1z+gg9NcrhNPYWw09oYODq19V1DGOkCO3x2mO5VFlAPxoP1l6t+E1SVcnlQ5Wwt3GAE2dtYDz58= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BN8PR12MB3587.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(366004)(376002)(39860400002)(136003)(451199015)(36756003)(6512007)(31686004)(31696002)(38100700002)(5660300002)(2906002)(186003)(6506007)(83380400001)(2616005)(66946007)(41300700001)(8676002)(66556008)(4326008)(6666004)(8936002)(66476007)(6486002)(478600001)(316002)(86362001)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?dm9uUHBXaTBmZ3h5dFYyNkxCZTBMb01wWTUwQVdjcVZIYXV3QnFKa0Y0UGZq?= =?utf-8?B?REZpOHh2WFR6bHRjVkE5QWFLdkJqYkQwOTVFMC9ydVBCVm1oOUlJMGhURmNN?= =?utf-8?B?UjJ6RzlHNWxoNWhCczd2aHhERVk2a0VCNGF3VGNnU3VzTStiTzVHa1dXbzlX?= =?utf-8?B?d25KNFhoYXUzWWlnaTFmWGdRb3VxLzAwTGNQelJtS1pyK0xEVUVTTkRYTXJU?= =?utf-8?B?aVhxZ3NPdHBueHk5K0pEaXF4RkJxQUNOK1FFMGRKOXVoaTNxMlpDcEl2RzVn?= =?utf-8?B?c3lyczhGcXlqdFh0NnZPbUFWT3lKUC9ZU2E0QUk4akxnRmRVaXNJMkUvTXJi?= =?utf-8?B?RUZFSG1zQUlPQUVRUEJQU0M4WjRRUnM2ckdFL0RyM2VNNFN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A9jLRZ+/MlyWqFyHFezzUZ+5zPou?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4915db9c-72bf-4886-8000-08dac3dbe796 X-MS-Exchange-CrossTenant-AuthSource: BN8PR12MB3587.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Nov 2022 11:57:27.8563 (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: +p5pecM9XUALHVHu/zoJBCsVfRNaqSxcVizvXZbPZKhCTw8GIJV9Lvyz4OgyMAxw X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5920 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 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 10.11.22 um 15:33 schrieb Dong Chenchen: > When p->gang_size equals 0, amdgpu_cs_pass1() will return directly > without freeing chunk_array, which will cause a memory leak issue, > this patch fixes it. > > Fixes: 4624459c84d7 ("drm/amdgpu: add gang submit frontend v6") > Signed-off-by: Dong Chenchen Good catch, thanks. Patch is Reviewed-by: Christian König > --- > drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > index 1bbd39b3b0fc..0e24d6b80e0b 100644 > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c > @@ -287,8 +287,10 @@ static int amdgpu_cs_pass1(struct amdgpu_cs_parser *p, > } > } > > - if (!p->gang_size) > - return -EINVAL; > + if (!p->gang_size) { > + ret = -EINVAL; > + goto free_partial_kdata; > + } > > for (i = 0; i < p->gang_size; ++i) { > ret = amdgpu_job_alloc(p->adev, num_ibs[i], &p->jobs[i], vm);