Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1389817rwb; Tue, 27 Sep 2022 12:19:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hLlVwe2txaSx0ad5r6mSNQsN/zusLQLZjQOWwcYePkuEBHblMznhrtfzR/xXuSIv79pvy X-Received: by 2002:a05:6402:5409:b0:44f:1e05:1e8 with SMTP id ev9-20020a056402540900b0044f1e0501e8mr29132957edb.373.1664306363764; Tue, 27 Sep 2022 12:19:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664306363; cv=pass; d=google.com; s=arc-20160816; b=XqCszFSjeKdSMn4FxVU4CyARpaw7JuOjpMpVFhJ5hxmi5eeDXYJvcjPOhR/jaA63GH Vq9m4KCjriXUjWBGqsvGTnwCtKgPz5C0EULNwKN1qy7A8XToFFKzed7/b0L94g2dq7Bq hEDKg1E7HzHDjY8CE5wOY3ElFfMObArt3HjzcR1KyR440rZxIat+RbtIUxGEJlh9uGIU urI3YvSNRK+FYO0iIKVBX5S/bDfho0OypP7Xzb7YJRkA2n0aMoDLT/UcFMgOqLnRvqOc aTScmW3DbieM0PH6ZYLeD7wCSyfbZ3tq/rZAex6XmQAcfhb3aFiR5Z7H27m76wKu8SpM N3Hg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=CKZDZsjqiLsVF9M4k7cLm8jOdzq2TFRsnP4krAVXE9E=; b=kxzLlWhvTFsbiwpsEa4FxnH0oENP/Mh4YD8tYVrBIN8uDxYcSrEIjczVhtC52riKwS Hq1SaaXKLo2n1cxvI7xHvgneqMFsjdUF/BTiuzUnZ1qLsYSsOlCUXm8K+CBwHUMJDouX aRW1VmPqB59SfStyAovYiBdEAZiVB12vxYqFOzfPiUJdBFcczMW5h9zBMrMmDlE3tdVy xBy6ybWBfd7w3ccbrTgUQiK47ueCr4KjfvmwgNQB0z4Qcc3QQt8zUvrjUD841qXW/Cgz VyVePe/5Ham50elQjuNSgO4G9eNhm/EQRsp3iUfAp4y19yEazas9CZ/EBlusnjLqqwyH ql+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fuxxsVPj; arc=pass (i=1 spf=pass spfdomain=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 sg8-20020a170907a40800b007317d093e6csi2083895ejc.808.2022.09.27.12.18.58; Tue, 27 Sep 2022 12:19:23 -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=fuxxsVPj; arc=pass (i=1 spf=pass spfdomain=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 S229572AbiI0TL6 (ORCPT + 99 others); Tue, 27 Sep 2022 15:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiI0TL4 (ORCPT ); Tue, 27 Sep 2022 15:11:56 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A36B109114 for ; Tue, 27 Sep 2022 12:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mHIJ6O27N4KEIfsJRyTVDg9eiwfdGfbKFAhiFZ/ciQ0AzU2SyvUyZNeMdEgeW4t+ZM3ZpBE/nZOeMjkEXkjNken2QjGhJrSwUseXf+yvzKB1ZJbues1EBCzUqIRqBAKhJGWlhkj3EiK0/zpxKKdsmGLX0mFaAdpEAlx2mqhg06iPahAsx2SqcmllA1bFe7X9pxnhgwFETFEyxs5Y7GaT4F5mrHQgHlaSyiemQDOuuf2vTkochnFcrnzLg/bGx4pqWmu2VTfuEJ43vp2Lb6G5V/L9q0/VoHyOWxpKW7OD3LOttUITnS8y/1bO6I31xsIfHuxhRvV+fDBSRlFHnqPdMA== 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=CKZDZsjqiLsVF9M4k7cLm8jOdzq2TFRsnP4krAVXE9E=; b=RQMYbHJByq5CnkqwfMtqeRcSG//CFw/yc4r9uCmDb4zEnC1D8VCHUjneOGdWuOxpZ6orwCoEogqlQKDP62aqTA7/9/ancbjRMyJ/wtbvcwsDUBpcOYqJYQp2JTj+uf5NorTqg2TvfrXj44jluRM9KWKp7WGT1NaXoh08yafR29ITm+aBm9krd5czBfZ2XVZkuJ288CR4SeKtXhiJOhXnUvxer798vN6LL2VNkiZHFSt9ftn/vkWIvoKIztvO+12nRXyo8hUX3CjNDnTNFrpBDELg6S1Q7VM7zEsC8lTrdnMAoXqsnYTejQlO9gi0MGDsdLW10VCBVw70XjxNAH2p5Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=CKZDZsjqiLsVF9M4k7cLm8jOdzq2TFRsnP4krAVXE9E=; b=fuxxsVPjTtiB0t1Jo0sXqbvRKSq/w/dQTkOURaPvvoERzxYkO5rx1B/LEyyzvV4q/KG16/5TwQoo1PemDjTnKGfxTDX2hPI3RaoCSWNmh/Aq+wb9EV9FQdD8rRFB22ziJej8pn1sHStr0OtaeduqFwxmw07/PFc4uMcGSFCsB/M= Received: from DM5PR07CA0108.namprd07.prod.outlook.com (2603:10b6:4:ae::37) by PH7PR12MB6000.namprd12.prod.outlook.com (2603:10b6:510:1dc::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24; Tue, 27 Sep 2022 19:11:52 +0000 Received: from DM6NAM11FT029.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::6f) by DM5PR07CA0108.outlook.office365.com (2603:10b6:4:ae::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24 via Frontend Transport; Tue, 27 Sep 2022 19:11:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT029.mail.protection.outlook.com (10.13.173.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5676.17 via Frontend Transport; Tue, 27 Sep 2022 19:11:52 +0000 Received: from hamza-pc.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 27 Sep 2022 14:11:49 -0500 From: Hamza Mahfooz To: CC: Hamza Mahfooz , Harry Wentland , Leo Li , Rodrigo Siqueira , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , "Lee, Alvin" , Alex Hung , Pavle Kotarac , Stylon Wang , Aurabindo Pillai , "Leo (Hanghong) Ma" , Hersen Wu , "Paul Hsieh" , Jimmy Kizito , , Subject: [PATCH] drm/amd/display: fix array-bounds error in dc_stream_remove_writeback() Date: Tue, 27 Sep 2022 15:12:00 -0400 Message-ID: <20220927191200.216488-1-hamza.mahfooz@amd.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT029:EE_|PH7PR12MB6000:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c90038c-282a-4c4b-5e4f-08daa0bc22b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n4OdFi39LJdSQujQInlP1aHo0Q+mBibBYo2kIV38mA06GZPt1KTTzwS+kArd0r+3YqLbGIz5FSQuVqXwPJ6b1UZWHffpXCAloi5P6kYHMnl9W3YMHY+e4AIM4CSjgYoArU12BGwgj4tUH17sqpyQ4bA29Q4QX9L51cR5MRWOvyoA7dvqivZAgPs8BSDK5RBQum8f/63cs+rF97eFrhWcmUdNjG6eyDSA+vr4LqVEQoiE56di+6gU7OPzwSjnD2l15oQTGlEbSSZn2vhomOTasq551lK0ij3ujyPAUFhCyOOCJrHPSxkU2HQy07nhsB6Tbhw9V1N8KAp3c6ltOH5TQMgbMT2sFE3kWIi1q8ftjqy2PHao3cdWiYmevHzBFMCgxcivPmFnUzSdSo+5dhTCVca9ijpQ5cPoT79qanA6ix8PJ0YUwQDGoMq+wqw6oMW565YPTDivTxXD4iTxDZ8PgBk9BEl1Uq8JWgA9BicxLfwTL8Iq8R9SPIdjE74NTXlD1Z6Ms2WANLcLoY0+J70EnRjpTg/RArjXN3OyQFNF1VUlz6O7P3D1ltKVCmUkod6undnV7myBwoR6VWCrPHMgRwtk5WTsNkhBJCoSG1HlZVp8YF9FyrteJjiceNP5UJrcG+AvmIsW/mlwahEtIrVapPAkGmImQAV+51U5xNcAapNSttWrmwgHNBkASK4JoakDoLVmxRH4f1ybR291IcCJwvFmEenXkavs8Bb8W2n2/mkXzbxOhW/BAaiNgNPXnA3DEY8nQ+r2KX9Lkc2L/gKabkPrMhLEwWWIGtVh0y60XOORarfN5bvghChXuCKe3zuVI/mlivXkn4KA4xL1LC38xQ== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(39860400002)(396003)(376002)(136003)(451199015)(40470700004)(46966006)(36840700001)(70586007)(4326008)(54906003)(6916009)(356005)(82740400003)(70206006)(36756003)(44832011)(5660300002)(82310400005)(8936002)(40460700003)(86362001)(2906002)(36860700001)(8676002)(83380400001)(81166007)(41300700001)(336012)(186003)(16526019)(1076003)(426003)(2616005)(7696005)(6666004)(316002)(40480700001)(26005)(47076005)(478600001)(16060500005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 19:11:52.1860 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8c90038c-282a-4c4b-5e4f-08daa0bc22b5 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT029.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6000 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Address the following error: drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c: In function ‘dc_stream_remove_writeback’: drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:527:55: error: array subscript [0, 0] is outside array bounds of ‘struct dc_writeback_info[1]’ [-Werror=array-bounds] 527 | stream->writeback_info[j] = stream->writeback_info[i]; | ~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc.h:1269, from ./drivers/gpu/drm/amd/amdgpu/../display/dc/inc/core_types.h:29, from ./drivers/gpu/drm/amd/amdgpu/../display/dc/basics/dc_common.h:29, from drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.c:27: ./drivers/gpu/drm/amd/amdgpu/../display/dc/dc_stream.h:241:34: note: while referencing ‘writeback_info’ 241 | struct dc_writeback_info writeback_info[MAX_DWB_PIPES]; | Currently, we aren't checking to see if j remains within writeback_info[]'s bounds. So, add a check to make sure that we aren't overflowing the buffer. Signed-off-by: Hamza Mahfooz --- drivers/gpu/drm/amd/display/dc/core/dc_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c index 3ca1592ce7ac..ae13887756bf 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c @@ -520,7 +520,7 @@ bool dc_stream_remove_writeback(struct dc *dc, } /* remove writeback info for disabled writeback pipes from stream */ - for (i = 0, j = 0; i < stream->num_wb_info; i++) { + for (i = 0, j = 0; i < stream->num_wb_info && j < MAX_DWB_PIPES; i++) { if (stream->writeback_info[i].wb_enabled) { if (i != j) /* trim the array */ -- 2.37.2