From patchwork Thu Jan 4 19:47:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Li X-Patchwork-Id: 10145783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 81EE96034B for ; Thu, 4 Jan 2018 23:22:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8BD22880A for ; Thu, 4 Jan 2018 23:22:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC7522881D; Thu, 4 Jan 2018 23:22:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5E3122880A for ; Thu, 4 Jan 2018 23:22:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9DC16E270; Thu, 4 Jan 2018 23:22:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 11895 seconds by postgrey-1.35 at gabe; Thu, 04 Jan 2018 23:22:39 UTC Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0045.outbound.protection.outlook.com [104.47.33.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id EC6B36E270 for ; Thu, 4 Jan 2018 23:22:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=+UdzYWD0rJKSn8HLpe/5WsWIhNsQwVSPER8a7EAyUv8=; b=c7HT3bET6riEwvwAdNf3A+NKHddbTejE4UzAoy6yjh0mxHjtDb2oCxTVBSsY+aIQzF0+SQp+R0I7XayyrxqQPZic7IyKcwm7Lr36pgbqdNB5LXRk8z3ANiGywvNavh0qxvfS4YMMsfMhiv1iNYRioocV2BC3DzpYt4u1tKh/Nb8= Received: from CY4PR1201CA0012.namprd12.prod.outlook.com (10.172.75.22) by CY4PR12MB1446.namprd12.prod.outlook.com (10.172.71.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.366.8; Thu, 4 Jan 2018 19:48:37 +0000 Received: from DM3NAM03FT059.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e49::202) by CY4PR1201CA0012.outlook.office365.com (2603:10b6:910:16::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.386.5 via Frontend Transport; Thu, 4 Jan 2018 19:48:37 +0000 Authentication-Results: spf=none (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; lists.freedesktop.org; dkim=none (message not signed) header.d=none;lists.freedesktop.org; dmarc=permerror action=none header.from=amd.com; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by DM3NAM03FT059.mail.protection.outlook.com (10.152.82.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.345.12 via Frontend Transport; Thu, 4 Jan 2018 19:48:37 +0000 Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 4 Jan 2018 13:48:36 -0600 Received: from localhost.localdomain (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.361.1; Thu, 4 Jan 2018 14:48:35 -0500 From: To: Subject: [PATCH] drm/atomic: Fix memleak on ERESTARTSYS during non-blocking commits Date: Thu, 4 Jan 2018 14:47:33 -0500 Message-ID: <1515095253-29817-1-git-send-email-sunpeng.li@amd.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:165.204.84.17; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(376002)(346002)(39380400002)(39860400002)(396003)(2980300002)(428003)(199004)(189003)(16586007)(72206003)(105586002)(5660300001)(106466001)(2906002)(86362001)(97736004)(356003)(305945005)(2351001)(53936002)(2876002)(478600001)(47776003)(4326008)(68736007)(8676002)(51416003)(77096006)(81156014)(36756003)(59450400001)(54906003)(50466002)(316002)(6916009)(50226002)(81166006)(49486002)(86152003)(8936002)(48376002); DIR:OUT; SFP:1101; SCL:1; SRVR:CY4PR12MB1446; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DM3NAM03FT059; 1:KX7gqABZaC+UfUPlt7TfUbhsxsXMCcKypeBk7DEe56k6xbX9Vn6pxcEIO3KhA3gl3yaL+Wxo7kyLIPXRTtXlVI2mykJt0U0cBC3hEMIjsvOwJpX1+uxJw0QXxTGaR/6g X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 854c6299-cc0c-409b-677b-08d553ac25cf X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060); SRVR:CY4PR12MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 3:u1b1GsVv+CvGSrN6Gc8RLPmRKEtNFNpNcrFwORsvBhU5TNZ7tcmq547z1/z6okk7gpVX6CaqXTUqg+9hFjlLXh3RSxhcGyeceoNzWfHBfbqAIM4xakkDQzvmYI8LTTJdwy4aGP7FS9dBXT6PzevmtJz8/UCARnbs7Jabs3zqzcGT/QEH/HPkchq494LkvY0UCPag3jJHX+x517o4SPxZJq9PQyx2NioyKfDDYMdykVEaQ2TzkurpBc8/WL+dIKrquH/OJQE6P2i0Q4b1ou31ULxCcdafYjePsP59Ln0qIrFg46/RepUkR3vrbfLbWlyzdyANjO0MTTuShXFkNsd2JonSCnbrZcy9KCDhspaP7hM=; 25:p5gXDLGT5hopx9RJPzAu5quF5bVGcw0vdYchFJw21VF0BwU6mYY3roMtvrwf0f6nxRrxRWP7YVxYQGn6NIuxM0yrwjJhMGqwI4p0Reb6IHyFDNdsHfsAa5dTrEpstuQqwiHtIU1Wgv8cY0YdtXAXSkQ/vMraV6dtahADVEB1Kix7+NvszK1rHH4DwaHY9ViQfdqDdepKX9bJ7jNY/RpgLiuewhK00AuAohVkzhUxNKYdGGxu1yB/hHMZvBTyyxdHQoUijJOB1+TvSPrBu8oJmIrSHzDkQ6g0aPiipsWRVLKp50p1jihthM9l/R5MLOoxnQPMNrdRfmbbT0mH63BtsA== X-MS-TrafficTypeDiagnostic: CY4PR12MB1446: X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 31:sEl7GBWSaRa+fKOhkQV18ng3O60O0DHt6dxa1lirudpIEI9H3wMMYXA6l8gWPui77Hh7wuv/1+oDP2ZobBbRTf4sTl3MBtCfLd73UB89Gqn7E01sTzPdn0deODU+zcdQJ+mitSRBDuCxDAG0614NJa1u+KH/Ygo42WwK+YuQiZEU4F+PqMGyHmnWBwGsNFzzRUYqu4QBGYsy6JRHwVjv2ahy1LccRSevnvJDSyZexaI=; 20:yCK7ll97jJTIhJx1h4bkF3yBHwxkdv4tq8tYmF4Nv96F2qH5ph9wQHcuR1eohhxNZGe4vLVJ/u+uCbQgTEUd+N0jIwiPG4NqWroroe8reez5hH2cq0Z15aGOAFz5GyctJxRwczliRnGbsLg5qTtQoAcYaLs/qt/I4HuWK3Si3tU4zYIOvRpTW+BveDCtHFe6gYwY0mb2mIYQXUPlxS9boySwYSztBUEuC19D9Ph8yZSNKFxjp9pSEQGjEHDE6WpY3LjgGHiTB67onUj5kKwKV9ENRiFi0cGxX7YloIlbCUtFT2PjFkpJtQPIHbbn2Q4JESoAH1N4z7Zj0aIqe4irVw3tvtG3gfUmrnj/e4zcd1wET9AREAGszqLiEzoUcDXDvU/tQS74hr5OZkIqI7sTNgwG4ukGUC/uxjgr9YU9TU3SidAnbNePgd5F+DgvlxVnyF39+sODP55EoFNZImWEHTEVugb/bE2TooEQgeuw0OMUglnMAjTwUlTEwVOOoHi/ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3002001)(3231023)(944501075)(93006095)(93003095)(10201501046)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123560045)(20161123562045)(20161123558120)(6072148)(201708071742011); SRVR:CY4PR12MB1446; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:CY4PR12MB1446; X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 4:YOlVH2O12IHxRCa0H38pPj976BZ7UPFv7490JcjqS2EwQxYyR2fKt+LOom6GxQaitC7cDoTRJKCsRhihLWwcnBvMJV1fwMxrKrnugFuOaHtEzrMIeDbR5O2/5n2CIYo8RjLO1Vx2XQvRh0pxJdx9duNWv8wYT1zUd3fJFGOG4FDZIw5wnHv1gtif9JgAjD7x3e9bVMGbN8YfmmgyWlZO1NAwq4QuDRvQ0yhyduRWhJEmDTzr2ob4wGTeAJIDojrbOSEeqRcmoyArIRBHDyXTMgA2SZ7B4D6fCd3qoKha56oemC+7GmSFA22ugDVUQPYc X-Forefront-PRVS: 054231DC40 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY4PR12MB1446; 23:NOatajfs+MWSNDwDy16xwLMA6uiK7s/J8Wh6XyigM?= =?us-ascii?Q?lrDVkJJJc3mp7B9+m02VeaqnGYHsPCjP5UMlVzuG93LRGGxeNYiVjuEq5cgn?= =?us-ascii?Q?HldPfgOWVcfux2V31EnNTCpsWbKQGAdT6BtFHiJZwlsjAWngIMvTcxNbcYps?= =?us-ascii?Q?CMQkVCn/wcJX1BunSnN+54vG6yaz1grxYdWegCFo4bYEwWzEUtvf51eqEKOW?= =?us-ascii?Q?vUCvfnlqRm9gkF0VsrA7+hxf1aPEOD/1mEx1J3537e8yyCGSr8eGEjBg5Tmx?= =?us-ascii?Q?Pj6QB2I12VFDJqY0eJEODGNFRK3A3y7209ihG8LosPQ+GmmrnHvAthjBfGJX?= =?us-ascii?Q?8ikzclnhNs3cQM64IOQqgnLw9OS0FctLF67lgowa3BpBR4qHU2whoRUUY3Lj?= =?us-ascii?Q?hzBAKdCn+SoMyUFIK2ZxTcOQjwgvgsnTc0hh8F/mJFItWjbldJVSRhZ/wfpl?= =?us-ascii?Q?tOE5IJI3EuyURd+OvhTnXGDg+8+Ln/7Dqy9W5p+RQU8aNhwDisJTW5zKaELM?= =?us-ascii?Q?+jHi8u0XcLxkyc140P1E7cgFb11OpG3f2Trha6DpJEvbIxIGkJ0eSeqDzH9p?= =?us-ascii?Q?KmNHlhrzKQbr3X/Xebn7Mbn//2MkLzoLG37L85vADroXjcgHEWNUFEj3IGu3?= =?us-ascii?Q?Nalk+haLXvgdNwuYNtHCeLsU9Ds1O0mS1id3TD4/u4bCi8JKf3xXei8ho5ha?= =?us-ascii?Q?EvS0ehwqAhzampRK8EhXSIRkDuFucc4nSdZjBpr2NMCu2i4ZlaODeCqJbhlV?= =?us-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UNBNp5d4SzpywMfGQ+om6cyMASyROwqANsXjlss29vGIAiO+TDZ3QcNvm+AaBQCawhQ64yIv6SXFkW8woRYT/hpdcIWR4YjeoW/QV/LiI0hiGJ5ifdz2efrBZhN3cj6vcK9hFhiui5AtLKGBd2CN4ryrxhExhMRtCJk9i0+zc3paL4MFL33/R81OU8pT1YKwnqRWKFitogrL7qIrNik SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY4PR12MB1446; 20:heBIGjEQTeYcZ37NjHQmnBjOT2kKpxPc9yLbZV7HYR9I/J1UNLq84CtdYSTzDGEiG/fdbrWVuhbNoLx2wBYR/Vfy2IcNC1zu01FZpU5cHr07vyrTMTSk00dNiNxWvFzFvd4QYopSC5xi13kpW9NYOHnqQ3aow+q0tIyoGBxaMhzA3Oe9o7mvsQTbHa9qhyd+RVecDXkF4MIRZ+gnFIHI8W9dKaFNEawQigC7IwTH37PKnY+fYujOldBWprxn/xrB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2018 19:48:37.5529 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 854c6299-cc0c-409b-677b-08d553ac25cf X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXCHOV01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR12MB1446 Cc: "Leo \(Sunpeng\) Li" X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Leo (Sunpeng) Li" During a non-blocking commit, it is possible to return before the commit_tail work is queued (-ERESTARTSYS, for example). Since a reference on the crtc commit object is obtained for the pending vblank event when preparing the commit, the above situation will leave us with an extra reference. Therefore, if the commit_tail worker has not consumed the event at the end of a commit, release it's reference. Signed-off-by: Leo (Sunpeng) Li Acked-by: Harry Wentland --- drivers/gpu/drm/drm_atomic_helper.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index ab40321..4253f57 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -3421,6 +3421,15 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state); void __drm_atomic_helper_crtc_destroy_state(struct drm_crtc_state *state) { if (state->commit) { + /* + * In the event that a non-blocking commit returns + * -ERESTARTSYS before the commit_tail work is queued, we will + * have an extra reference to the commit object. Release it, if + * the event has not been consumed by the worker. + */ + if (state->event) + drm_crtc_commit_put(state->commit); + kfree(state->commit->event); state->commit->event = NULL; drm_crtc_commit_put(state->commit);