Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2439911rdb; Fri, 8 Dec 2023 08:10:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEmTJzo3ztRvhe9qEzN+uvSYORPXJfn6v4TbwcN+Qv9b0YZLPJx41JYZF6ViLxbOYg1o0PF X-Received: by 2002:a17:90a:8b92:b0:286:bc8c:a232 with SMTP id z18-20020a17090a8b9200b00286bc8ca232mr280063pjn.24.1702051817956; Fri, 08 Dec 2023 08:10:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702051817; cv=pass; d=google.com; s=arc-20160816; b=UQLecWVjslUStQr/9rDZbmv7QvR9WBym2jyqY0y2ECqO+P0TwdjsLF8/LcZXIQSAAz mZFTsca7r27AyLHeNKiP+SPwmOb/t0/3k7WW0dhSGBmvT8h43dvQ8v+f1/m/3JCg6iHl 6ihkOYBkwegnnjWVI3QqUkUtwwApGahIHKYGDZPeGSD/49/7mDnZboNnYhbpsdG5JYPo IhvDfV/mH405SfNCF0J0hriZfNUTo9RRFYMmOvWHiwYoiMZKpmi1jy8pens+CfAA1PjH gjRMrSwBiqhjYBA2g1ahNATBnUQZYw4OoLwm04RMSuBGhLSmOTMgDYcF6nm7DHKkd4tq UdSA== 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 :message-id:date:subject:cc:to:from:dkim-signature:dkim-signature; bh=/7F7ce360aZxFvc7l164Z+IqsHGXLg+mnKLYoXjxy5s=; fh=SGQjrbBhN1ceZFGYVIJKEV8VqdgbzBFzvb9s/5hpKqA=; b=GZnKxt7VB1keZQVPo/tu1PI1Y3MPM5ZpG9LvvuSd3v+5HuOKbH5hNIPJ5/CmQLjLqe /ZpaOvOIO130YBZ1s65N0/W3IthIwdfnBqG5IJH8rebch/o51gBa9YTMfuuKaq45kyfR wvrOpt4sct/9S20LcziMDY7VmUQ29Q1+Rz5D4h5hNcpPwacEQChpBG3EldjIADCQ2SQ+ qYzp/E/CoLa/b3iTDe4ZfN5vpbUeeMDh+wnwFrvs87xYq49lml8kdS1yDmpoCUeFcvWk LJpnDAfAY7e4u6gbjHTbK9VPdMtvwsTyG1irW5pmFOYcnn3MLyK8T15G6aMQaBh1ro/1 0xgQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@imgtec.com header.s=dk201812 header.b=RzSpOsTB; dkim=pass header.i=@IMGTecCRM.onmicrosoft.com header.s=selector2-IMGTecCRM-onmicrosoft-com header.b=OmiFRIus; arc=pass (i=1 spf=pass spfdomain=imgtec.com dkim=pass dkdomain=imgtec.com dmarc=pass fromdomain=imgtec.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id z7-20020a17090abd8700b0028a2692fae7si1666848pjr.152.2023.12.08.08.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:10:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@imgtec.com header.s=dk201812 header.b=RzSpOsTB; dkim=pass header.i=@IMGTecCRM.onmicrosoft.com header.s=selector2-IMGTecCRM-onmicrosoft-com header.b=OmiFRIus; arc=pass (i=1 spf=pass spfdomain=imgtec.com dkim=pass dkdomain=imgtec.com dmarc=pass fromdomain=imgtec.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 69088813553F; Fri, 8 Dec 2023 08:10:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236008AbjLHQKB (ORCPT + 99 others); Fri, 8 Dec 2023 11:10:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235948AbjLHQJv (ORCPT ); Fri, 8 Dec 2023 11:09:51 -0500 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E409173F for ; Fri, 8 Dec 2023 08:09:53 -0800 (PST) Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3B8FCaBu016280; Fri, 8 Dec 2023 16:08:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h= from:to:cc:subject:date:message-id:content-transfer-encoding :content-type:mime-version; s=dk201812; bh=/7F7ce360aZxFvc7l164Z +IqsHGXLg+mnKLYoXjxy5s=; b=RzSpOsTBHIP+D4ua7h0IATNgJO4a4UWkODVCq WBbKJhbNNUluuPMqEJX8PpLQXYKDLg4glSgoblCxiQ7wUhiaie/pEClFjYDVNiuP cDYPVKRHbnEWrlk30MaT8jlSCgShsXmr9Sko37z61dgyg56RMOnRcs9rQ+JETcZj eWG7Apv/h2cGrUaly25zxesOs46Y4zJJ3IUfCIvJbNUiw5bdjcpU37oHi/nMT+p1 VjrzQARrkGte5BNhzL1sTIVo5ltSo9552R3guIR0pLA5RS6CMeXyqidGWU0Pfojd ipSOQ8i5AJBdrugVTrYWqeIvFHeVEHdTETZCNScTnAcVCmnFQ== Received: from hhmail05.hh.imgtec.org ([217.156.249.195]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 3utd11a5y6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 08 Dec 2023 16:08:47 +0000 (GMT) Received: from HHMAIL05.hh.imgtec.org (10.100.10.120) by HHMAIL05.hh.imgtec.org (10.100.10.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 8 Dec 2023 16:08:47 +0000 Received: from GBR01-LO4-obe.outbound.protection.outlook.com (104.47.85.104) by email.imgtec.com (10.100.10.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Fri, 8 Dec 2023 16:08:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wt/9zigxYPXFRPvaLG4vfudpd348XszWPLsd1aYj7ia/gIKHjZRGxITVKfMtOXR1EHsncw9rHgGnGgaMQX3v0svJOxCn4MqpIkcpueJRrl9qu7GtFa44DmGniQphCeqxfuqfjkSOL7qMzoTiSuhecHywLNQJMtRioLJOkXkZVc2kODNvMwqGIruGFZ/a8nOLDlUoJHOzmBesQvM8ZggRRRCbWNEfQ/MwzRE4ZzeklZ06nHM1b/oTXHywxeQkot094d81/+VYOTNSSIuqyyjJpzqWVgIqi/PfpI3a2EyaDG8xWYqQfNGC174SPb2nFHOdC8pdoFmO601rANPH09+QaQ== 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=/7F7ce360aZxFvc7l164Z+IqsHGXLg+mnKLYoXjxy5s=; b=OlQqSPSP2vNA5KMbgHwHKQKo8uKt7g6qCgK/Fig5Dgv1o2eifkKI0LaSab+Aj9UGKtqmHoR8i/SYjC3mJXcoqgIVhl7Wx4JK61x0A3FLhATXCcMo7XbtJ5Ze9bmvkDb6ClEFFZVe6pemXqHxewQCFxLBMbwKe6/f7wXZTznn3QBjPTCyUQTtD14XxR5QbbqXBWEd4J8OiDbycdpcx7AeDi2kCU6lFT91Mq3WYfVY45Caioy4XnVxYG/zuYRMFjAEHtI/LnHQnfF8zw/LYTB5v9li/phx2bJqp/DgN5tzTl7Fpqdpi0X0mxsTQVEORMhc5ao5owMSvpCs+MmBEcBY2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=imgtec.com; dmarc=pass action=none header.from=imgtec.com; dkim=pass header.d=imgtec.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=IMGTecCRM.onmicrosoft.com; s=selector2-IMGTecCRM-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/7F7ce360aZxFvc7l164Z+IqsHGXLg+mnKLYoXjxy5s=; b=OmiFRIusYzu8P59QYG5IG0eww2w2i6gGQ7mUoYtIPKNKLpYSr1wlFAQ9NCuZRWupYYYoAK3gwObnF3CZ6oFvjzjIzeFgASCz14o+WnKsJHRPMnZWKtyoRaOQOICivxiZFOxI/D3I0/0IIw9Ddfoac3cJPVGAp89XoxRu8BDZGJA= Received: from LO2P265MB4600.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:23c::11) by LO0P265MB6228.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:24e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.28; Fri, 8 Dec 2023 16:08:40 +0000 Received: from LO2P265MB4600.GBRP265.PROD.OUTLOOK.COM ([fe80::a3f5:aa1a:ff75:79a2]) by LO2P265MB4600.GBRP265.PROD.OUTLOOK.COM ([fe80::a3f5:aa1a:ff75:79a2%4]) with mapi id 15.20.7068.025; Fri, 8 Dec 2023 16:08:40 +0000 From: Donald Robson To: , CC: , , , , , , , , Dan Carpenter Subject: [PATCH] drm/imagination: Fixed infinite loop in pvr_vm_mips_map() Date: Fri, 8 Dec 2023 16:08:25 +0000 Message-Id: <20231208160825.92933-1-donald.robson@imgtec.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: LO4P123CA0242.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a7::13) To LO2P265MB4600.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:23c::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LO2P265MB4600:EE_|LO0P265MB6228:EE_ X-MS-Office365-Filtering-Correlation-Id: aa37c0bf-e381-462b-c6e0-08dbf807f18f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9QpRKBGhmZffcJPn7Hj7ZLs5ohVeLjJCe3sLwyiy25sxvHsBPjJDbjcBS0PqLh+Fh2pE3bML3ieLip41b9VioH2+kmFioGqumf97KO9rgoPkONf5GSwt/0aMilfzZjzRe7pcg3UDXLgWadB1RJ2O7Fk1RKiZd70Hk62V8rDG/yG8gnVL9FQkqrm80Pdk5Gzry8yJhYytTjZe5rpMiKpgJLHWmduisRJNPBX4aPFye/iSRj3UdyOJPQG3RhEBS7/BU5/KQfb68iNM6VipnMUsOErlawD/ZbE6nOFLTxJZAxdnFWO6bYkO6pPIUDZMZWzW4xhEeeJDaF1Gko/5NJ8Nw7LLTh73To/zphGCj1bvnY3qhA0vwDgsx70VLV1CCjFrCO2u6UYhZFzgX4YyZe3yvHlZMXqCt38lJLAUziGRz0h0hQ6ZRvcsAHXjAGSN2EjKGs4IjvyZy1vmmDj0/rkfzNREmh9cervWtFhUFnz/W8wC8NFMwq3JeYmUjhYUtQt8IYvuT731KvkHbu+qXZ1VcTwZ6u+egJjyi1MJYY/VQsw2d1MoS40QYQnMbj3bdMGcmQ+tVy4tc+RxFXUOhEAcK1JY3RwibJT8PqewN8XDIOkb8tQvrGS+K1shIena3hG2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LO2P265MB4600.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(366004)(346002)(136003)(376002)(39850400004)(396003)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(5660300002)(66556008)(66946007)(66476007)(316002)(83380400001)(2906002)(478600001)(44832011)(6666004)(6486002)(8936002)(8676002)(4326008)(86362001)(38100700002)(52116002)(41300700001)(6506007)(36756003)(6512007)(1076003)(2616005)(26005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?13WQxwHcFeeBaF3CSjBbrfJOah947NNsqpInR3BTV+iCLq2okek9d3YiioTM?= =?us-ascii?Q?Et1FeyEWXrFas5hF9BOszFJ+qc4G2vKa61yLfuMD8Nc+ujzQ5wk9hyZoR/2a?= =?us-ascii?Q?oGLXNvVz8mLRCzcK9Y50uXIA72kckTUWrE6Dy2JrYI2eOVwZ7DpMu+xRTMhn?= =?us-ascii?Q?oUXwUkmIV9ITWQQ9mFGa5aHIHxVAkikORI8fOMg04sW+AJTvL4gxWSBbxNvr?= =?us-ascii?Q?Fluu8dO999N2FrGqSfVshdtq4KKx9VuSACoavo8aKvfd0A3ZKKL7HqXNU0Ub?= =?us-ascii?Q?XSBBmnemhODCKIUW8HHjtCU5vLaHnNkVkzb72EyEyL13Lqt8BOzUg81jYPtV?= =?us-ascii?Q?G4QKWNCEojlb3wa8C9wvsJK2jEXP13g1EQtOj10Odv0LmLZcgKuUzHX4NAem?= =?us-ascii?Q?I/sI8g5bgQ8abwW1/KSJlENiVCDmwztdL0/pHQQ2/1f658imwrVtH83ErpEz?= =?us-ascii?Q?PWdb/djLN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v8hP?= =?us-ascii?Q?QrCHO+kcD487zEUcmIYAE9uWZCvpe+A9vVP9bxDa4Chs65GBPac/BNrO/IiO?= =?us-ascii?Q?r9Qjy6CoYcfoSg3I90jJvq4ITDX36/1vl+9wkMomjmrexDplELeUT7ckCPTr?= =?us-ascii?Q?ZnFOFwu46w5QB6Lnfi+eCK+XJhEIG/e0j9h6Vncs6bvRBAKl5ar5Q127i18R?= =?us-ascii?Q?Lrb900bJBso1A4rpbiKEH7k3WMm+CY0DMWf4cpzDPWfjGuD/xVIu0XuWyN63?= =?us-ascii?Q?qw=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: aa37c0bf-e381-462b-c6e0-08dbf807f18f X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB4600.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2023 16:08:40.5463 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0d5fd8bb-e8c2-4e0a-8dd5-2c264f7140fe X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pRDTk/aWDcHKG0PBnRUyFBRC3QrPuHg7VBhK0ygv1uERSozM3QDOqvQ93woprpudDjRhWLhxLEmAC0cXAChawJv9rAww5KblA7qAfXHgyXs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO0P265MB6228 X-OriginatorOrg: imgtec.com X-EXCLAIMER-MD-CONFIG: 15a78312-3e47-46eb-9010-2e54d84a9631 X-Proofpoint-GUID: 0xZeGb7dLckUgYh16dTydqZzT57u3B1u X-Proofpoint-ORIG-GUID: 0xZeGb7dLckUgYh16dTydqZzT57u3B1u X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 08 Dec 2023 08:10:15 -0800 (PST) Unwinding loop in error path for this function uses unsigned limit variable, causing the promotion of the signed counter variable. --> 204 for (; pfn >= start_pfn; pfn--) ^^^^^^^^^^^^^^^^ If start_pfn can be zero then this is an endless loop. I've seen this code in other places as well. This loop is slightly off as well. It should decrement pfn on the first iteration. Fix by making the loop limit variables signed. Also fix missing predecrement by modifying to while loop. Reported-by: Dan Carpenter Signed-off-by: Donald Robson --- drivers/gpu/drm/imagination/pvr_vm_mips.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c index 2bc7181a4c3e..b7fef3c797e6 100644 --- a/drivers/gpu/drm/imagination/pvr_vm_mips.c +++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c @@ -152,8 +152,8 @@ pvr_vm_mips_map(struct pvr_device *pvr_dev, struct pvr_fw_object *fw_obj) u64 end; u32 cache_policy; u32 pte_flags; - u32 start_pfn; - u32 end_pfn; + s32 start_pfn; + s32 end_pfn; s32 pfn; int err; @@ -201,7 +201,7 @@ pvr_vm_mips_map(struct pvr_device *pvr_dev, struct pvr_fw_object *fw_obj) return 0; err_unmap_pages: - for (; pfn >= start_pfn; pfn--) + while (--pfn >= start_pfn) WRITE_ONCE(mips_data->pt[pfn], 0); pvr_mmu_flush_request_all(pvr_dev); -- 2.25.1