Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1937035pxb; Thu, 16 Sep 2021 20:54:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyv/xah2Br5GXAzw+r2HjQRFZl6XoYot9/uNAT7Vhu+yInneFYbjYe/fKWRWi0z4bXhM2gC X-Received: by 2002:a05:6402:c10:: with SMTP id co16mr10535403edb.327.1631850849868; Thu, 16 Sep 2021 20:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631850849; cv=none; d=google.com; s=arc-20160816; b=RDncF8DkNCzgS9bAAiw/q9UpHyoiymefxeuqxBkRsnKckI4evtOhS0chm+uEJ05sD5 yqDpFY9BAUvRnEN5aOelf1+D6p+vnzO8NF2Ot0r6bY+KiMFqODQ2bRoMW4Nj/84muAvD 3MeHFrEluRqD3xJH2GW+0lHd+kc3NtdgYdvVST+LqwaAuHGuz+tZoJfYWJP9Dx8CJpu4 tSwa/MdMHRePSSgXoKaLXQNZrk9owBz69Myv4oF1QDObvfpFZgSJ+onyfboZ7z04+LqW T+zZxqyU9gDSj6XZIDFTBWGRDtGw9htfnhbv2MMYMcaQ7sn6iJy5LLsRiWxL5hq/Ccn8 8Mhg== 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=HsqiT0Lb8gP2UuQSZPvWReBuSHHWIG38csj/VMTC1D4=; b=EEjCEl4Lz8jDGdhFvbZc4lpbViVF1DTgbMkR2Rg56qlA7VtVEuag7HaS+w7AGyqpsm grEjfUv/ZdrecYMSU9it6RzYaQSzAah+XfADhobO11LybVKSNEtUYeSlM4pFMe251yh1 1f6ICOkuyjuhSCC5niYh7HpTOXFu/9GyGSbUpYGwqiGYzC4e16F0ft6JA6AaVUv4xN6K Wwx+4kvTF0ocJOCK/GzpYlC/KUP0afBIcxShIiNaNTd76CbKiKJV6uT4cG6kyaFToXvk NXjQKHN39iOHrB47ETP7a3gkj8AVpb5q6ILEDJEO93m4uoLvUOvEu70h//NjvUZoFqLw gL+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AHcfNif9; 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 gv23si5498171ejc.249.2021.09.16.20.53.45; Thu, 16 Sep 2021 20:54:09 -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=AHcfNif9; 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 S1353548AbhIPReV (ORCPT + 99 others); Thu, 16 Sep 2021 13:34:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:47082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352542AbhIPRYv (ORCPT ); Thu, 16 Sep 2021 13:24:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0731361BE6; Thu, 16 Sep 2021 16:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810649; bh=UZWytWGmXwex4+/1vb6H6PHBd6Zm9qo4AOXiHRecuTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AHcfNif9+SODKdUsGodJY/O0LZiViU/A2XPcnIOcVYSLRHo2ccamBGmFbq7DPn8W2 RYZgmbaLqb7HF4vdRHuiCnT9pHAzpzbb7fyXR6dMhxmbG9DomSTW6JqAIgdSHv8Yde JsEBUDUGgsWNo6zPJCH8FChk5DtmpftHQIQdi3Lc= 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.14 218/432] drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit Date: Thu, 16 Sep 2021 17:59:27 +0200 Message-Id: <20210916155818.233037950@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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 873995f0a741..6002404ffcb9 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