From patchwork Tue Jun 19 14:45:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lipski, Mikita" X-Patchwork-Id: 10474651 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 06192601D7 for ; Tue, 19 Jun 2018 14:46:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDCA728D5A for ; Tue, 19 Jun 2018 14:46:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1BD628D5F; Tue, 19 Jun 2018 14:46:07 +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=-5.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 33FC628D5E for ; Tue, 19 Jun 2018 14:46:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC51A6E25F; Tue, 19 Jun 2018 14:46:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from NAM05-BY2-obe.outbound.protection.outlook.com (mail-eopbgr710062.outbound.protection.outlook.com [40.107.71.62]) by gabe.freedesktop.org (Postfix) with ESMTPS id AC34D6E25F for ; Tue, 19 Jun 2018 14:46:03 +0000 (UTC) Received: from DM5PR12CA0071.namprd12.prod.outlook.com (2603:10b6:3:103::33) by MWHPR12MB1200.namprd12.prod.outlook.com (2603:10b6:300:f::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.863.16; Tue, 19 Jun 2018 14:46:01 +0000 Received: from CO1NAM03FT042.eop-NAM03.prod.protection.outlook.com (2a01:111:f400:7e48::202) by DM5PR12CA0071.outlook.office365.com (2603:10b6:3:103::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.863.16 via Frontend Transport; Tue, 19 Jun 2018 14:46:01 +0000 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Received: from SATLEXCHOV01.amd.com (165.204.84.17) by CO1NAM03FT042.mail.protection.outlook.com (10.152.81.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.884.17 via Frontend Transport; Tue, 19 Jun 2018 14:46:00 +0000 Received: from SATLEXDAG04.amd.com (10.181.40.9) by SATLEXCHOV01.amd.com (10.181.40.71) with Microsoft SMTP Server (TLS) id 14.3.389.1; Tue, 19 Jun 2018 09:45:59 -0500 Received: from mlipski-HP-EliteDesk-705-G2-MT.amd.com (10.180.168.240) by satlexdag04.amd.com (10.181.40.9) with Microsoft SMTP Server id 14.3.389.1; Tue, 19 Jun 2018 10:45:58 -0400 From: To: , , Subject: [PATCH] drm: use atomic helper function to get crtc_state of crtc Date: Tue, 19 Jun 2018 10:45:31 -0400 Message-ID: <1529419531-24044-1-git-send-email-mikita.lipski@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)(979002)(39860400002)(396003)(39380400002)(346002)(376002)(2980300002)(428003)(189003)(199004)(86152003)(106466001)(478600001)(81166006)(36756003)(81156014)(4326008)(476003)(26005)(2616005)(126002)(316002)(110136005)(16586007)(2876002)(8676002)(105586002)(68736007)(336012)(72206003)(54906003)(59450400001)(53416004)(77096007)(53936002)(2201001)(86362001)(48376002)(356003)(2906002)(50466002)(1857600001)(50226002)(5660300001)(186003)(426003)(8936002)(47776003)(7696005)(51416003)(6666003)(97736004)(305945005)(486006)(2101003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR12MB1200; H:SATLEXCHOV01.amd.com; FPR:; SPF:None; LANG:en; PTR:InfoDomainNonexistent; MX:1; A:1; X-Microsoft-Exchange-Diagnostics: 1; CO1NAM03FT042; 1:Q/Xz7EaB3eQCMqb2ZwAyrD0FE8XJNO1Kd3Zxvh9L/ptLCEQB9ZsekEZf+aLfMzM5qvBzRGMTVdiHTBzAFtlb//GmPsFboz2cFnxGRlRFPjKUimVMewtyLImhqyKG54It X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8855a625-c8a5-454f-0823-08d5d5f35fcc X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(711020)(2017052603328)(7153060); SRVR:MWHPR12MB1200; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1200; 3:V80tCOjCcaln70lrlVZ49tk14WCG7niVy2iKpO6te5gVOy6RBHsJM4Cj1C2bcRidVcoIiYEMDIYkc59s1NliHz2pXgP/en1gHVz+psvRbR1TJX1/mMwa/rpTJ+n2C2scng7b5AKI6DWrLjQHuMSBMS94mjQPUT7zzPwErZo4O9nxybByL+Zr6HUOm2okMTdJO2FPNqZICtMF+AjQuxcaG0qh+AzfcLHwT6/gaBjqHBBdQQuwgpmfM5HN+F046gbG34YmrFEg7ObN08dOxx+s+COLTbRh+q4lb3UvsREJ41J9zLApWQuAEMia7cE3D+KIcEs+88rc4z3nEPAhAbuG6AB8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p3CXMoFxBiP2Je9xPnsInrTxdBSpbcp6HAotwbQoq8TRKGHU18W1bMhZ5FhkUA+0RXAX953cnp9rjLLOf/G/qrac25HsDKgIG+s X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231254)(944501410)(52105095)(93006095)(93003095)(3002001)(6055026)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016); SRVR:MWHPR12MB1200; BCL:0; PCL:0; RULEID:; SRVR:MWHPR12MB1200; X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1200; 4:VryxXL3j4ax9siKevtpejiJ8zsH1i0hAtwZjSaQlbkixRMCFyQ+AGZkU6dO+afgFxbUdrXJMOv3dw4mmvxiQOflGcDXWI+Ztt1Fau0N8dbWX+KEsDelBa4MbgLeWKfhWDi7X8ZwPf75Q40/ZhxlyYzoUgm6HIAKt+V41nOTABhKHWlB5gHHMVz2PHF0iqNMn39MgzAv3ZWSwJmerPGbxpSTmxm82FbHQAjzDkVU79MjsMElPBA/YHbPYw9hAhnF1RUvcEQV58RctJjkzviq+nKe6E5ETtx/6VDOA3qDXFLY= X-Forefront-PRVS: 07083FF734 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR12MB1200; 23:aKwoAuXAUS+S7URA6FkyQk6GrM12STzDtdXZbLMbn?= =?us-ascii?Q?ruO1MEwfnll90i5xad2Vw60fFYkrt71RuqzG6gOEV1CohGk7SVKsPhmdOSzD?= =?us-ascii?Q?WPKo9l3ndTSO9n9DVwPBF8E4cKoxh4tD2tOKVriTbc3tjXv4kT5A4GAkqIEg?= =?us-ascii?Q?wBSGRdETVLbeKUsxWp7heCs3eu5hTJ8Ke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HuB+/uCpz1AcG//U9k4eWwisUU+1p1H/rurC7wzxbVU0NtDNy0LNfldeH3Blxv878AB4nE9i5SobK2LxwGj4x+oQ==; 5:+gmMc4IbTbD2Mo/KRK85LpBMEEgkNNfpz6qDkMptCv+aJ1BWotATGezYJegFQ21rdYTe+ZTfi1fFZfcZnJ/7356pcR+mKp+l7YaOwocJzY41KH79+iLOBqYbij0k0pk5jDsVZa3XtGUHVg38KCzhxqvg5Yb3VZtuZ0Ht0pXcVsk=; 24:fpI+eTs5eW3AZFBCdIey/YjCYJCLi6MiJCiIDp40pzhyj3HtT8EIW1gIAgkh8nFyAzfP19MH5mcUBJwcfrNsw38+bBzyx4jxQIZT89dGI2g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; MWHPR12MB1200; 7:elxM4UBCQ5OrAM72iSe163huG5s3WDHP+34O2xcOg0irW3jzA9rv8qXss16OAiF67V4wS8N7HnIH5JAW/7a0uwAbJ2KvyndBYvmXiamr9RATx4hgzMZScsm67pFgVKe1hdDmm4f5PKxO3ZEpMaMYa55tUuCR+xBtpyjqTmw25qzAqpqvvQ6YfUWvh5CGB0bJ3JQpYsWTMZSlSl84FQNt2cq1WKIC1gc2wqJEpIrdAH4uBoJAvl4/h3zArBvQObmG; 20:wdUqoTOQEShcYzWmX6GmzBPJYiGXH+dqPc/fjd4KBo//Q5mfvgcMDR5T5kYYtnerkEMRQiohsU8K2EkrS3Jl7rWAL1Nf4D0B2M4rUjUPTH8Cf83LMs8OdybFgT9dZboAvkUOYqPrEH1A3k6Id4lNhVQ0WkI99//T39bjOuiKJcSZ9uoxHGHtJ3IORcBiie+3yzRjhxiMukS8dwUaIGl4yR33+w6EEXOBW5VsFNrcYo40O9Ai409F6r0oenwKNpVB X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jun 2018 14:46:00.0175 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8855a625-c8a5-454f-0823-08d5d5f35fcc 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: MWHPR12MB1200 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alexander.deucher@amd.com, Mikita Lipski Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Mikita Lipski Use drm_atomic_get_crtc_state to get the crtc state in case it has been previously freed, that might prevent use-after-free issue. This patch fixes the bugzilla bug: Bug 199425 - BUG: KASAN: use-after-free in drm_atomic_helper_wait_for_flip_done+0x247/0x260 Signed-off-by: Mikita Lipski --- drivers/gpu/drm/drm_atomic_helper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index e8c2493..e083f85 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -1276,9 +1276,11 @@ void drm_atomic_helper_wait_for_flip_done(struct drm_device *dev, int i; for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) { - struct drm_crtc_commit *commit = new_crtc_state->commit; + struct drm_crtc_commit *commit; int ret; + new_crtc_state = drm_atomic_get_crtc_state(old_state, crtc); + commit = new_crtc_state->commit; if (!commit) continue;