Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp583459pxb; Mon, 25 Apr 2022 17:16:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVwhUJvBRR/4H1SbyPS62krYtEnkUm08APhoubqAWZzCAVPawIN8ZkwWnsgDgtJLLv0AZa X-Received: by 2002:a17:906:3918:b0:6e0:5bbd:bf33 with SMTP id f24-20020a170906391800b006e05bbdbf33mr18641139eje.764.1650932197950; Mon, 25 Apr 2022 17:16:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1650932197; cv=pass; d=google.com; s=arc-20160816; b=NpMRdoqrPEAleEc2q9BwkCBf6mSdEs7QKL6DV0TfEXLxh+bLo41w14Yg5hGacnYYCN bXPAolVYoOwKKvM5403ErPR5SYOgBYQWuN13m1ZnVU6w1QDZpq8+uwR9NdWoK29IUfA8 9P1lBk5A6yJLTJfIxiw2h1DH7njS/FL60wqNYQIdeqP89p7KJH9DJFzAOcl9l8oQmOVM oC2hhbAGLhnqRgyu5afb1Km0X1lrBgrGhiYWHQQFhOgwR60oFYveaUXlGwNZ+Sowxgm+ SyJI6EwI9Tjv3AJ/BUAxjvHNvHKFk5xaP3UWJgvhNvewKuELo/SFyDxgix5pT/CdTRA5 8/dg== 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=4r5LVmuy33I4I6Wm0epx7EXL6GIo7Xl6nw/G4jtm6ug=; b=ccvGCBfwrPiHrjBhV5ru5+UGsvq5apg9bmV3xzsPXJjlMVDspP9/RLurBDJ2G/uAAs 8GRl3fnpHvUuM1H4lOzx2TZDIM1UQxHofVdvEZbXkcxMcmj3xlMqzdSSx48aXiwyb77y ncFfeOo1Gcsx4RwPvi9rS8D7jvhWrDi+RMIN5m7ppPJTWicCVht8Re7bT1agy7k2wIMm nFDT7uImS0tcm7XI8Z/pNEtskj9Tq3/GFVILaAafh8wrWBgczzrh/tmgCvd7OqyytmXP 0L4xnY9wKR+8JvOTUkcNHKl/aE1kX2789lZyYKQzYatOCpNIdMUwzkPxHO0Q+O2ftviB AQLw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Z5za6+S3; 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 p21-20020a170906605500b006ee402acc45si13767314ejj.166.2022.04.25.17.16.14; Mon, 25 Apr 2022 17:16:37 -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=Z5za6+S3; 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 S242959AbiDYPpx (ORCPT + 99 others); Mon, 25 Apr 2022 11:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234777AbiDYPpu (ORCPT ); Mon, 25 Apr 2022 11:45:50 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2080.outbound.protection.outlook.com [40.107.94.80]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 243AE38BFB for ; Mon, 25 Apr 2022 08:42:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J41YB/KU7txszTc4NoGE2EcL6Bs4iDGsCMjZmvrqlQ9U1nzenR9zdeS0h8Dat53lJ9nY6UWZab8kXFtyJXVANVIBxqti1K55zdV+gNE7EcB3mSaJ/UgFPOg+qjuiy98E24YtrpqFithJEj0vP/yiU2mCU1G+Y/3rSElybBMMtLxmEaNnRGq+QQoGnVDNrzgOHqOBccK+ykke2Oq5/hVY0EOngVdrVXw4AN/XIKAaNV5areqn/J6wj23B0FrppZtbjjjMcK7cyWvT0cFsIWD5ae2Mylkr9MAYYnF1uOD6NIWhO1LCI0LEX8lwp9PvwaYMtIXPPWpubmYJ79Nvd5+e3w== 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=4r5LVmuy33I4I6Wm0epx7EXL6GIo7Xl6nw/G4jtm6ug=; b=ktCPHM7I7FZxworPeZY0+ExWX852zRRaDlWtB43cAomagzLUG69dJure4yUkIVnCQFORqTiXxnTNo3zlkAfJcSvlXNLqCki4HkpfMQS8mAIlIdbVI60X5NZz7WJYnSWO35xrTn9JRVnVFjeZ7vEqkie/dhOOEFCLfgsHmbwg12/92Qq6oFVohF6PYJjKwzIvVwD0oOXeMWW2OsS51/Omj7kocVaArLEKO6Nb82rFI4XIBaGlfCkXZ9QNKZqO3oz/gRMbYJNGykfl9Nc1GaziJ7UF0JiTwpRqbx5mXAJhVqZTgi4XGc8tQmNEACmqb9zURbkr8oX6wKa/F6QwxeoOuA== 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=4r5LVmuy33I4I6Wm0epx7EXL6GIo7Xl6nw/G4jtm6ug=; b=Z5za6+S3/DdOGCvmHghqQdFFuFAUuQHkdFHWd2zyW0zlJURtOtn0p1KHRGwgCO4eOmWlVpD+Ei3zHhSVCnXXyKj8bXIxePsXBEhcJ+trySAPg3qPZENFF5m1wD3FqqCV5bDy3fUZIxm9CcLmW+O16I/Ea/474FQo2E9GV2BWJUQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1947.namprd12.prod.outlook.com (2603:10b6:3:111::23) by PH0PR12MB5500.namprd12.prod.outlook.com (2603:10b6:510:ef::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 15:42:42 +0000 Received: from DM5PR12MB1947.namprd12.prod.outlook.com ([fe80::1ce8:827f:a09:f6e]) by DM5PR12MB1947.namprd12.prod.outlook.com ([fe80::1ce8:827f:a09:f6e%5]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 15:42:40 +0000 Message-ID: Date: Mon, 25 Apr 2022 11:42:37 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] gpu: drm: remove redundant dma_fence_put() when drm_sched_job_add_dependency() fails Content-Language: en-US To: Hangyu Hua , yuq825@gmail.com, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, lima@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20220425083645.25922-1-hbh25y@gmail.com> From: Andrey Grodzovsky In-Reply-To: <20220425083645.25922-1-hbh25y@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MN2PR20CA0064.namprd20.prod.outlook.com (2603:10b6:208:235::33) To DM5PR12MB1947.namprd12.prod.outlook.com (2603:10b6:3:111::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bf588f0-ea32-4bbc-ef7c-08da26d23b34 X-MS-TrafficTypeDiagnostic: PH0PR12MB5500:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: flDgKB2MALHT9DURuHn8mEbdI3X8F6fPE1CYHUJrazdROHE9yBSYk+MtR8rgd7O+p/otJbAXado7dVDig5nJedxNaG2BNV9myGaPogWz5Qnk1+//2TE/1eUWRDAd/HXCMMgJU5M0ew3L+zWqqOInuGC8QOPZouGJj5L3dJeRhOydSlEB9UVB8okomUSK8zboPpvkioOvVfYehHAGBhdIQToYIm6r+XqLRGAx760+P9+RRQ/SbCMuHQW7e5rzFX/7pobXqk06fD+9eVANY9pFYrUTbPYWqWrCuIDx9XiC4SDZHJ7iEpa0y6HnJrrNiPFEdj0w/dQ6wz1JX7pSaspH3oQdtBGxnLqDGEDxLzaLWzXfz312wm/5xeufUoM7W8daO8qmtjvM0oNUuV2BSJve3y7VRlKCoCOC91Mie0Cnoj2tGtXs2laTXirzUbu9TLcTb7T5cKqbW3KkM3ySDauBwKImGIX5TWXal37E7fZOJGo1WIdCU2v74jMsRmIGaZFqnltmPktq5CB4EQTlhBCsxEalbjsHQrV2SBk1RBTvdw9guBgYt2Jf4BbIVCvJeE1d9TBGKzAu1An+0441FGHcHbDcVUm7QXXTnbLLk3pmCXyGk62UWkIj2+dRw0VUD7mpr6OjTGnPsts2G6LViNvqmb445KJ1HUiw9AdooK1l6LJcMMvxNl4bAPZSVgcIUDVXONxoRFLJrTTcaeU13Znxy4SzW1diFE3koeDjOSdhC6s= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1947.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(6666004)(8936002)(31686004)(36756003)(6506007)(6512007)(53546011)(5660300002)(508600001)(6486002)(8676002)(66476007)(44832011)(83380400001)(66946007)(86362001)(31696002)(66556008)(2616005)(316002)(186003)(2906002)(38100700002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?bjFwV1d1Ky9zamtiQXpreW54Nlh2RVRWUmFiOEFEUFFuL0RqQk1remhkTE8v?= =?utf-8?B?NVVsMGpSU2NMdElCZ0gzYm02eVhJSUlvUUtORXBpTU0zZHFHTi84TGZpVE5I?= =?utf-8?B?WTVQem5rUjhMWTBhMWQyY1hrc1B0aHNhQ0d1SHdPZzVxd3pLTW5QMlZ4bC9w?= =?utf-8?B?bmRSU2VRNFJSQk8yNlNKZGVhNERTK2J3TDlCa1RwSFE0N2JMTHRiUnZUNE5K?= =?utf-8?B?U21LUEtaclhiYzRLUDFJUktEaVdyUC9UZzF6SkFuZUtmOFFkK3h3Y2dKRkgr?= =?utf-8?B?ZG5CTURSdFFuRUpKS1VHMGVXcUx6b2dXZ0xyYXRuaUNLYk11Rm8xZGVUNTVr?= =?utf-8?B?dnV6dzNkRW15UGNmZmdnbWFRaDR5aTNxU1plQ1hya2RadDRXRUk5b1R0UExX?= =?utf-8?B?UlcxR1YyRkVxanMyWlB4eERxamtoZ0Uvek9NME1EOEhSLzZBQlNDd0U5azht?= =?utf-8?B?NmRNa0xMY1VWalZvV3R6dTRRTE9VM1ZZa3ZCcjdZOHgvQldla242Qm5VckVF?= =?utf-8?B?K3Jy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kkreUVUQ3pNdGxUYVcr?= =?utf-8?Q?ItygUpeABTcsTZPy2kXDqFar7Rq0HkhieiNC25WyS1WmD?= X-MS-Exchange-AntiSpam-MessageData-1: lqgutPOuBOlKUQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bf588f0-ea32-4bbc-ef7c-08da26d23b34 X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1947.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 15:42:40.8408 (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: LD8Q1EIBFgxTy8WCwOkwW/Tg8fat5GBQHSRahf8rCSFHxdQbn6E+hJ6NkhGgWWobgBoIYOYbQhS3NbDywZNFTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB5500 X-Spam-Status: No, score=-4.0 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 On 2022-04-25 04:36, Hangyu Hua wrote: > When drm_sched_job_add_dependency() fails, dma_fence_put() will be called > internally. Calling it again after drm_sched_job_add_dependency() finishes > may result in a dangling pointer. > > Fix this by removing redundant dma_fence_put(). > > Signed-off-by: Hangyu Hua > --- > drivers/gpu/drm/lima/lima_gem.c | 1 - > drivers/gpu/drm/scheduler/sched_main.c | 1 - > 2 files changed, 2 deletions(-) > > diff --git a/drivers/gpu/drm/lima/lima_gem.c b/drivers/gpu/drm/lima/lima_gem.c > index 55bb1ec3c4f7..99c8e7f6bb1c 100644 > --- a/drivers/gpu/drm/lima/lima_gem.c > +++ b/drivers/gpu/drm/lima/lima_gem.c > @@ -291,7 +291,6 @@ static int lima_gem_add_deps(struct drm_file *file, struct lima_submit *submit) > > err = drm_sched_job_add_dependency(&submit->task->base, fence); > if (err) { > - dma_fence_put(fence); > return err; Makes sense here > } > } > diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c > index b81fceb0b8a2..ebab9eca37a8 100644 > --- a/drivers/gpu/drm/scheduler/sched_main.c > +++ b/drivers/gpu/drm/scheduler/sched_main.c > @@ -708,7 +708,6 @@ int drm_sched_job_add_implicit_dependencies(struct drm_sched_job *job, > dma_fence_get(fence); > ret = drm_sched_job_add_dependency(job, fence); > if (ret) { > - dma_fence_put(fence); Not sure about this one since if you look at the relevant commits - 'drm/scheduler: fix drm_sched_job_add_implicit_dependencies' and 'drm/scheduler: fix drm_sched_job_add_implicit_dependencies harder' You will see that the dma_fence_put here balances the extra dma_fence_get above Andrey > return ret; > } > }