From patchwork Tue Nov 22 13:07:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 24356 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2190533wrr; Tue, 22 Nov 2022 05:11:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf42srpz0901FzZ3seK12LAHOXuJpVXu3bLouTUKIl+OoAGUrOwSNRmKmCPbJuBbJNNr0yna X-Received: by 2002:a17:902:7686:b0:177:faf5:58c5 with SMTP id m6-20020a170902768600b00177faf558c5mr4959004pll.166.1669122695734; Tue, 22 Nov 2022 05:11:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669122695; cv=none; d=google.com; s=arc-20160816; b=vMEeVIFbuhmzG52zBmxvShpXHV6hKYTh5uk0dDcDgl2B5ODXpj4orWxCezfmYozre5 nw2vEWrTwMcOexxW/Qra+jp7WPnCQsxkX0r69RYD1u2fisXYzRgJI9JHn1b9hfhSpxcd 4MW6YNHelbwZDAsX4Z0iJe+WiNtv+AJJDxTypoU3TTtfqHV6J5iAxT99qTzG3MKIy+X0 jlUA1efsS7EIQJSQ0yBJ9JR7gOwTZgyxh287eRCCliWH3AO6UhqK4y5D/oRP/+KU9y22 DJCF8zhBiilGdMCojRAPd7VkB2OCLnbzecxab5zFROApHAv3NXSNg7cN4mT3tmqIrx5Q 8oBA== ARC-Message-Signature: i=1; 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:dkim-signature:from; bh=Lwqi47KLlf+3se6EowjmL8XqQoZpHqyKwAHzX3T03qY=; b=H+5gi7rQPkGnG5NXYTi/+YtKBlMtV8GT0cH/W8pVVXY6ohjghz2zTrTqgxcSOnX4bC ghi9lws+N2OMxK0N604xxR5pUXG6/XwdNJ/I9q6Zy1O1Y1RpZIHUORz18mu+pXbGQ+9Y t83NkNBu7i5ji8G4+sqW754tyYJiUKOyI+LQ5q48QbEF/VsRTFeTCQUKO5zb6B8O8ERp MGpMXBKXQxq1d3ps2InWwiiFy0sFd6bJPtRKIiowaL+8LS8CWHV75P2ET/uiXjcGxijZ ljUdTSZ64HpPs/xz7/LbhLL+3oKd1Y2Upr4ChI5GEKb+dWmKxSqcifyGHVesmkiN0fk6 dFKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=i2VYqD2M; 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=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id om3-20020a17090b3a8300b00218b999150csi5325469pjb.142.2022.11.22.05.11.20; Tue, 22 Nov 2022 05:11:35 -0800 (PST) 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=@swemel.ru header.s=mail header.b=i2VYqD2M; 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=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233175AbiKVNIH (ORCPT + 99 others); Tue, 22 Nov 2022 08:08:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232972AbiKVNHy (ORCPT ); Tue, 22 Nov 2022 08:07:54 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242BE10E2 for ; Tue, 22 Nov 2022 05:07:50 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1669122466; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Lwqi47KLlf+3se6EowjmL8XqQoZpHqyKwAHzX3T03qY=; b=i2VYqD2MMJrb7FwHOZ5DvkAcxlMqgQBYCi1LOlVzp/AZxHfAe1oPPzhs667NWMtJydanlX PGW6skwbrIfUs2wdJkzZjMxSqIXhAmyR96qq78Ppbzg1iZuqm7S2yR4LEHn1yRn1CAGXMG WASvflA1/G2zE+JGw+jL+JFMtc0BG6U= To: Evan Quan Cc: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: Date: Tue, 22 Nov 2022 16:07:46 +0300 Message-Id: <20221122130746.24432-1-arefev@swemel.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750202000121321393?= X-GMAIL-MSGID: =?utf-8?q?1750202000121321393?= Date: Tue, 22 Nov 2022 15:51:44 +0300 Subject: [PATCH] powerplay: hwmgr: added result check The return value of the 'div64_s64' function called in ppevvmath.h:371 was not checked. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Denis Arefev --- drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppevvmath.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppevvmath.h b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppevvmath.h index dac29fe6cfc6..82aa7130d143 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppevvmath.h +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppevvmath.h @@ -357,6 +357,7 @@ static fInt fDivide (fInt X, fInt Y) { fInt fZERO, fQuotient; int64_t longlongX, longlongY; + int64_t result; fZERO = ConvertToFraction(0); @@ -367,10 +368,11 @@ static fInt fDivide (fInt X, fInt Y) longlongY = (int64_t)Y.full; longlongX = longlongX << 16; /*Q(16,16) -> Q(32,32) */ + longlongY = longlongY << 16; - div64_s64(longlongX, longlongY); /*Q(32,32) divided by Q(16,16) = Q(16,16) Back to original format */ + result = div64_s64(longlongX, longlongY); - fQuotient.full = (int)longlongX; + fQuotient = ConvertToFraction((int)result); return fQuotient; }