Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1684406pxb; Thu, 16 Sep 2021 12:56:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf9Mxs2XCi7jo82sexKfMUsU2np6PtYFjACptJw8lpW5NJ/CIpkBjPHz8Pcnk+fMNJ9fe2 X-Received: by 2002:a92:8702:: with SMTP id m2mr4979408ild.250.1631822166358; Thu, 16 Sep 2021 12:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631822166; cv=none; d=google.com; s=arc-20160816; b=d16LKeF0zVwIzUr6vqkGOoNWMhDdSKnK0hQtN6CvJbCja60yETekifGb35Q/Vcm6PY RL63dXCuHapiJDZF3ua7xOxc0nDVWJJTIh6EvJvmw0WaATlZ2kjxr02TzJG/LVKI8daA BRUICHbzeO0CMJ6r4k6tsd3OZubDujD73NHY9pcy5SOY/wLuqHRLiDrP2jkGFd22MnMV plQj5NJw3u8Ianj1aqDtDkecNOGYdBfA98Zu5OEA2Vs6Ta7RLuPkOuJXeBOFOvbehduA on9Q6uc9FUjELzkpk250tt6YcmVWBehbkJjKnjn08RYahbtk9d+nyzC9IUzaGySUZ2C1 kW/w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=GjXFcaF1HYyoUmH2nmZtT/m7bMouNBWPa5WyjLwI1dQ=; b=oxETjJLe21RvswEDkQi6/vyJM1e/1S+emEki+yg7Ss7P3McK06HPr0xy9rzILCXQYe OoPDOLWodUNj2y0QgAmAYDX55NQN4SoZM2vXu3iNocavi/WNU8BGJz/5Cv0j+8jxd6kM XbRPol4VArc8lGKFdc4rWJ8/WWtJiUV1Blo6gpTgWMQ8OQp5NXhANdrhUiOsEGhrnh/p hgmmd1bKQBvcrrTokGCExlH1a9EZwSSvGZgrpARDuVC/iOoOwaHzUftZ6gC6I0jToR2g FgZRho8Cs2FMfffGgktN/Aje7jLVcU7iNXQ8jApb22IyIkYftKml2WadLfsmKrgF2qjb Ly2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J4hvoDJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c18si3692891ioz.59.2021.09.16.12.55.54; Thu, 16 Sep 2021 12:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=J4hvoDJT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233967AbhIPQXQ (ORCPT + 99 others); Thu, 16 Sep 2021 12:23:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:49032 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239499AbhIPQNU (ORCPT ); Thu, 16 Sep 2021 12:13:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADC0D61130; Thu, 16 Sep 2021 16:09:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631808597; bh=6dNN8OQPe/wsB34uoI/ICMKD2qSsK5yWqTj8ezysK4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J4hvoDJTaNBDBnLL34ofPh1u+rWKfuQmz98f+FaAoEq8A6oBj6aVnLrMdA0+DmGiT Jz3Ws7IwJq5aA5fHuG4FvNCqhZOyOhZIscZyjrgUTDtdTT7J6+ayywGsp8GJBJPyu9 V+d/6VrZYXuRAfwnz3OX7zrUKXqkHpTT9Hy32/z0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , Fabio Estevam , Laurent Pinchart , Sam Ravnborg , Sasha Levin Subject: [PATCH 5.10 152/306] drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit Date: Thu, 16 Sep 2021 17:58:17 +0200 Message-Id: <20210916155759.259566163@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155753.903069397@linuxfoundation.org> References: <20210916155753.903069397@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Geert Uytterhoeven [ Upstream commit 47956bc86ee4e8530cac386a04f62a6095f7afbe ] As nwl_dsi.lanes is u32, and NSEC_PER_SEC is 1000000000L, the second multiplication in dsi->lanes * 8 * NSEC_PER_SEC will overflow on a 32-bit platform. Fix this by making the constant unsigned long long, forcing 64-bit arithmetic. As iMX8 is arm64, this driver is currently used on 64-bit platforms only, where long is 64-bit, so this cannot happen. But the issue will start to happen when the driver is reused for a 32-bit SoC (e.g. i.MX7ULP), or when code is copied for a new driver. Signed-off-by: Geert Uytterhoeven Reviewed-by: Fabio Estevam Reviewed-by: Laurent Pinchart Signed-off-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/ebb82941a86b4e35c4fcfb1ef5a5cfad7c1fceab.1626255956.git.geert+renesas@glider.be Signed-off-by: Sasha Levin --- drivers/gpu/drm/bridge/nwl-dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c index c65ca860712d..6cac2e58cd15 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -196,7 +196,7 @@ static u32 ps2bc(struct nwl_dsi *dsi, unsigned long long ps) u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); return DIV64_U64_ROUND_UP(ps * dsi->mode.clock * bpp, - dsi->lanes * 8 * NSEC_PER_SEC); + dsi->lanes * 8ULL * NSEC_PER_SEC); } /* -- 2.30.2