From: Colin King <colin.king@canonical.com>
To: Anitha Chrisanthus <anitha.chrisanthus@intel.com>,
Edmund Dea <edmund.j.dea@intel.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
Sam Ravnborg <sam@ravnborg.org>,
dri-devel@lists.freedesktop.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH][next] drm/kmb: fix potential integer overflow on multiplication
Date: Fri, 13 Nov 2020 12:37:45 +0000 [thread overview]
Message-ID: <20201113123745.36799-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
There is a potential integer overflow when multiplying various sized
integers that are cast to u32 integers using u32 multiplication and
then assigning the result to a u64. Fix this by casting MIPI_TX_BPP
to a u64 to force the multiplication to use u64 math and hence avoid
any potential overflows.
Addresses-Coverity: ("Unintentional integer overflow")
Fixes: 98521f4d4b4c ("drm/kmb: Mipi DSI part of the display driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/kmb/kmb_dsi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/kmb/kmb_dsi.c b/drivers/gpu/drm/kmb/kmb_dsi.c
index 4b5d82af84b3..6c3081356bd9 100644
--- a/drivers/gpu/drm/kmb/kmb_dsi.c
+++ b/drivers/gpu/drm/kmb/kmb_dsi.c
@@ -1369,7 +1369,7 @@ int kmb_dsi_mode_set(struct kmb_dsi *kmb_dsi, struct drm_display_mode *mode,
*/
data_rate = ((((u32)mode->crtc_vtotal * (u32)mode->crtc_htotal) *
(u32)(drm_mode_vrefresh(mode)) *
- MIPI_TX_BPP) / mipi_tx_init_cfg.active_lanes) / 1000000;
+ (u64)MIPI_TX_BPP) / mipi_tx_init_cfg.active_lanes) / 1000000;
dev_dbg(kmb_dsi->dev, "data_rate=%u active_lanes=%d\n",
(u32)data_rate, mipi_tx_init_cfg.active_lanes);
--
2.28.0
next reply other threads:[~2020-11-13 12:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 12:37 Colin King [this message]
2020-11-13 17:56 ` kernel test robot
2020-11-13 18:16 ` kernel test robot
Reply instructions:
You may reply publicly 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=20201113123745.36799-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=airlied@linux.ie \
--cc=anitha.chrisanthus@intel.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=edmund.j.dea@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sam@ravnborg.org \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome