From patchwork Mon Nov 11 13:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Murad Masimov X-Patchwork-Id: 13870775 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 46760D2E9F0 for ; Mon, 11 Nov 2024 13:56:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A4B4510E4B9; Mon, 11 Nov 2024 13:56:14 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=maxima.ru header.i=@maxima.ru header.b="aqdgVia9"; dkim-atps=neutral X-Greylist: delayed 497 seconds by postgrey-1.36 at gabe; Mon, 11 Nov 2024 13:56:11 UTC Received: from ksmg02.maxima.ru (ksmg02.maxima.ru [81.200.124.39]) by gabe.freedesktop.org (Postfix) with ESMTPS id F114E10E4BE for ; Mon, 11 Nov 2024 13:56:11 +0000 (UTC) Received: from ksmg02.maxima.ru (localhost [127.0.0.1]) by ksmg02.maxima.ru (Postfix) with ESMTP id C0A011E0006; Mon, 11 Nov 2024 16:47:50 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 ksmg02.maxima.ru C0A011E0006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maxima.ru; s=sl; t=1731332870; bh=8tXd0LJo0Wnt8jjrZ2luigCRDhUjB19IfjB6lhPbGzM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=aqdgVia9jt7wANQk0R34mmmSgtIc38sm5cUps8TzIPkqf7cMbSv5mxzFK0x/Nt+is y7EWmz6ijtNOVy5ql7Adp4GXB5ytv7tZ7AhQBqZynF60DAHw23A3ef9yVpWTRec71D pnQz02hfdwo4osKumZkkEz2fmjd1GKb767IEXEpq7Zqn31R2AH8/9TXmRp1QfubOzM 3FQX76vRG8Cqhz0ZLdN4Cigfrexc+01COus3ZFVGgvKHa3cFb+o2jDUkSrmwfQs3Ku T3knU7RyB+fEU2u3Fpou2PlZhXYBKr+xFvdxsMrTOYZNfTfB+X0n70844d8oTdNZEV 1RYnOUhRLks9g== Received: from ksmg02.maxima.ru (autodiscover.maxima.ru [81.200.124.62]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.maxima.ru", Issuer "GlobalSign GCC R3 DV TLS CA 2020" (verified OK)) by ksmg02.maxima.ru (Postfix) with ESMTPS; Mon, 11 Nov 2024 16:47:50 +0300 (MSK) Received: from GS-NOTE-190.mt.ru (10.0.247.217) by mmail-p-exch02.mt.ru (81.200.124.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.4; Mon, 11 Nov 2024 16:47:49 +0300 From: Murad Masimov To: Dave Airlie CC: Murad Masimov , Thomas Zimmermann , Jocelyn Falempe , Maarten Lankhorst , Maxime Ripard , David Airlie , Simona Vetter , , , Subject: [PATCH] drm/mgag200: Apply upper limit for clock variable Date: Mon, 11 Nov 2024 16:46:39 +0300 Message-ID: <20241111134644.1507-1-m.masimov@maxima.ru> X-Mailer: git-send-email 2.46.0.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.0.247.217] X-ClientProxiedBy: mt-exch-01.mt.ru (91.220.120.210) To mmail-p-exch02.mt.ru (81.200.124.62) X-KSMG-Rule-ID: 7 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 189084 [Nov 11 2024] X-KSMG-AntiSpam-Version: 6.1.1.7 X-KSMG-AntiSpam-Envelope-From: m.masimov@maxima.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dmarc=none header.from=maxima.ru; spf=none smtp.mailfrom=maxima.ru; dkim=none X-KSMG-AntiSpam-Info: LuaCore: 41 0.3.41 623e98d5198769c015c72f45fabbb9f77bdb702b, {rep_avail}, {Tracking_from_domain_doesnt_match_to}, ksmg02.maxima.ru:7.1.1; 81.200.124.62:7.1.2; 127.0.0.199:7.1.2; maxima.ru:7.1.1; d41d8cd98f00b204e9800998ecf8427e.com:7.1.1, FromAlignment: s, ApMailHostAddress: 81.200.124.62 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2024/11/11 06:58:00 #26843820 X-KSMG-AntiVirus-Status: Clean, skipped X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 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" If the value of the clock variable is higher than 800000, the value of the variable m, which is used as a divisor, will remain zero, because (clock * testp) will be higher than vcomax in every loop iteration, which leads to skipping every iteration and leaving variable m unmodified. Clamp value of the clock variable to the upper limit, the same way it's done with the lower limit. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 877507bb954e ("drm/mgag200: Provide per-device callbacks for PIXPLLC") Signed-off-by: Murad Masimov --- drivers/gpu/drm/mgag200/mgag200_g200se.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.39.2 diff --git a/drivers/gpu/drm/mgag200/mgag200_g200se.c b/drivers/gpu/drm/mgag200/mgag200_g200se.c index 7a32d3b1d226..69402a591f59 100644 --- a/drivers/gpu/drm/mgag200/mgag200_g200se.c +++ b/drivers/gpu/drm/mgag200/mgag200_g200se.c @@ -218,6 +218,8 @@ static int mgag200_g200se_04_pixpllc_atomic_check(struct drm_crtc *crtc, if (clock < 25000) clock = 25000; + else if (clock > 800000) + clock = 800000; clock = clock * 2; /* Permited delta is 0.5% as VESA Specification */