From patchwork Tue Nov 22 15:36:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 24438 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2283948wrr; Tue, 22 Nov 2022 07:40:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf6RNO1NgJ4JcrkGaww4Hm58xYxFKAiOelMTSOzdy/E/F0fjhbVmce8FHxMOP/qoEz5pHQYc X-Received: by 2002:a17:906:2854:b0:7ae:3684:84b0 with SMTP id s20-20020a170906285400b007ae368484b0mr12042997ejc.622.1669131620304; Tue, 22 Nov 2022 07:40:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669131620; cv=none; d=google.com; s=arc-20160816; b=g9cUbKRzluMNSJTCXcIgyj95vK2/ROYifjw7HyKvd8nzlWntpeDx33ibMp8jPYFg/4 2lgWRNAjFvr0Do2jTGJJ+0Xi+qZ0zppaWnp5cIr5+hho7pZ5sxNZHr+bgtd+cunF/ML1 C5rb7xP0jiy4LL8k2bLrlm4jgLMoCNpSEebAOmS9hGZho9naGXD3m2EpzRBbJBA7lcnU wxKlSw1IGbnCmAzHgEzDUPZ0bEuuzbSCtF6TGSEFBaP+5k2YEs/vFYStscMIUIhSk9KO o9Qp30uaJkK0OB8UgI+8vp8gDC2Mb9a/a7myAJmXUKhKXz6fqfqB4eNjiW8cHYJgGVBz Rnhg== 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=f8yks6Nly8vAvHQB6r3QpAU5Ke7J6yBlMIAgEuvrAOM=; b=Zu2KOt/xw/S0oxtaVnAPZPUinQMF8RPY148I/X655WDPN0jtagBGArl/bstWp7TYJH dhwE969qilNK1mohXHC0F8cBCx7uTXU70LY9h0inTZ8hmgvRTZreTUGOsq5PBejk+/gm d8b+n5saHlvA76iXo/z+iFcgjiW4iY3fmx4kYPf7HT/JvsJrbZ+49EcFtidghaDzpwO2 SaTZPegC83426a2VTfQGFWc2FMv+zBhYQ8DRBK3H4ua6mUAo5341RYHHWgwWMzzgrkNn wDXsuJEPz/7YmF/WXrqsf9DgEBJ7soopHKWk0ohI99P97fvuoQGH1ziHJRXJYC3fflRZ R/9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=asKczoD4; 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 m9-20020a170906848900b007adf9d69424si9779836ejx.586.2022.11.22.07.39.55; Tue, 22 Nov 2022 07:40:20 -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=asKczoD4; 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 S233740AbiKVPhV (ORCPT + 99 others); Tue, 22 Nov 2022 10:37:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234153AbiKVPhB (ORCPT ); Tue, 22 Nov 2022 10:37:01 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 313436C73B for ; Tue, 22 Nov 2022 07:36:58 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1669131416; 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=f8yks6Nly8vAvHQB6r3QpAU5Ke7J6yBlMIAgEuvrAOM=; b=asKczoD4dJp2+N/Cet6LXyR2LzNIHadPUGMIXX2juB59YA0JHdumreH3Kubgw7sEnvsdW8 UM5OcWzjMxxzqqXdFna0SjdvLqC3MtIdwy47eC3YGmhY9QxD4DIZsENrLZmFvYvj+Aapzj bUTrydDqt/QnwHnRZeGR7/0eXRcnpr8= 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: [PATCH] drm/amd/pm: added result check Date: Tue, 22 Nov 2022 18:36:56 +0300 Message-Id: <20221122153656.28495-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?1750211357884678941?= X-GMAIL-MSGID: =?utf-8?q?1750211357884678941?= 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; }