Linux-Next Archive on lore.kernel.org
 help / color / Atom feed
From: coverity-bot <keescook@chromium.org>
To: Jun Lei <Jun.Lei@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>,
	Alex Deucher <alexander.deucher@amd.com>,
	Tony Cheng <Tony.Cheng@amd.com>,
	"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
	linux-next@vger.kernel.org
Subject: Coverity: dcn20_update_bounding_box(): UNINTENDED_INTEGER_DIVISION
Date: Mon, 4 Nov 2019 09:40:38 -0800
Message-ID: <201911040940.91FAE4C@keescook> (raw)

Hello!

This is an experimental automated report about issues detected by Coverity
from a scan of next-20191031 as part of the linux-next weekly scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified
lines of code (noted below) that were touched by recent commits:

f18bc4e53ad6 ("drm/amd/display: update calculated bounding box logic for NV")

Coverity reported the following:

*** CID 1487397:    (UNINTENDED_INTEGER_DIVISION)
/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c: 3142 in dcn20_update_bounding_box()
3136     		// FCLK:UCLK ratio is 1.08
3137     		min_fclk_required_by_uclk = mul_u64_u32_shr(BIT_ULL(32) * 1080 / 1000000, uclk_states[i], 32);
3138
3139     		calculated_states[i].fabricclk_mhz = (min_fclk_required_by_uclk < min_dcfclk) ?
3140     				min_dcfclk : min_fclk_required_by_uclk;
3141
vvv     CID 1487397:    (UNINTENDED_INTEGER_DIVISION)
vvv     Dividing integer expressions "max_clocks->socClockInKhz" and "1000U", and then converting the integer quotient to type "double". Any remainder, or fractional part of the quotient, is ignored.
3142     		calculated_states[i].socclk_mhz = (calculated_states[i].fabricclk_mhz > max_clocks->socClockInKhz / 1000) ?
3143     				max_clocks->socClockInKhz / 1000 : calculated_states[i].fabricclk_mhz;
3144
3145     		calculated_states[i].dcfclk_mhz = (calculated_states[i].fabricclk_mhz > max_clocks->dcfClockInKhz / 1000) ?
3146     				max_clocks->dcfClockInKhz / 1000 : calculated_states[i].fabricclk_mhz;
3147
/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c: 3145 in dcn20_update_bounding_box()
3139     		calculated_states[i].fabricclk_mhz = (min_fclk_required_by_uclk < min_dcfclk) ?
3140     				min_dcfclk : min_fclk_required_by_uclk;
3141
3142     		calculated_states[i].socclk_mhz = (calculated_states[i].fabricclk_mhz > max_clocks->socClockInKhz / 1000) ?
3143     				max_clocks->socClockInKhz / 1000 : calculated_states[i].fabricclk_mhz;
3144
vvv     CID 1487397:    (UNINTENDED_INTEGER_DIVISION)
vvv     Dividing integer expressions "max_clocks->dcfClockInKhz" and "1000U", and then converting the integer quotient to type "double". Any remainder, or fractional part of the quotient, is ignored.
3145     		calculated_states[i].dcfclk_mhz = (calculated_states[i].fabricclk_mhz > max_clocks->dcfClockInKhz / 1000) ?
3146     				max_clocks->dcfClockInKhz / 1000 : calculated_states[i].fabricclk_mhz;
3147
3148     		calculated_states[i].dispclk_mhz = max_clocks->displayClockInKhz / 1000;
3149     		calculated_states[i].dppclk_mhz = max_clocks->displayClockInKhz / 1000;
3150     		calculated_states[i].dscclk_mhz = max_clocks->displayClockInKhz / (1000 * 3);

If this is a false positive, please let us know so we can mark it as
such, or teach the Coverity rules to be smarter. If not, please make
sure fixes get into linux-next. :) For patches fixing this, please
include these lines (but double-check the "Fixes" first):

Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1487397 ("UNINTENDED_INTEGER_DIVISION")
Fixes: f18bc4e53ad6 ("drm/amd/display: update calculated bounding box logic for NV")


Thanks for your attention!

-- 
Coverity-bot

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201911040940.91FAE4C@keescook \
    --to=keescook@chromium.org \
    --cc=Jun.Lei@amd.com \
    --cc=Tony.Cheng@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=gustavo@embeddedor.com \
    --cc=linux-next@vger.kernel.org \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Next Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-next/0 linux-next/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-next linux-next/ https://lore.kernel.org/linux-next \
		linux-next@vger.kernel.org
	public-inbox-index linux-next

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-next


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git