Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp446707pxb; Thu, 9 Sep 2021 04:48:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6F39mimb1bTyApFh6xP+C9I2zrKAmbwQfwKVzM4iP+1SCz84IrCXlIK0HckXR8ypYmFNn X-Received: by 2002:a92:d2cd:: with SMTP id w13mr2139168ilg.292.1631188086433; Thu, 09 Sep 2021 04:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188086; cv=none; d=google.com; s=arc-20160816; b=xOLgysqXJzONtGayNOWblvZID5S3jnQoGge6eDsWorsghKbqePnMkT0+uF0zpZz6SZ AupoVn7iW6DEMHusUF05K65L0k+nCClPg/6vOQ0MtutDpuZlJaqc1bIeL82oZVLupTRk otLctt0l5BStqSf2diLZYqQFTRLKFUMVS/fi+BipUnsoB2MPJkqK33pU/qy3bFaW7Qqr g5CyV2PDqCy3ba5P9iZl88XpbiYHIVTTwG9M1Ed5j7vXbbTbUeP3jgl5n7ZTCLuri0cV 5EM7I33NMV05epXVUQ26Rj1YEbthOJt3nmJHsxC8edvqKX7xyLZGLMG1bd1kc28a1Wzy 8qrA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HsqiT0Lb8gP2UuQSZPvWReBuSHHWIG38csj/VMTC1D4=; b=l3OA6hnYkXkKnjEe5oghlrZUzxkmIT0AusdDOBOj5tbVexB15GKxJQl3nc84lCJdb0 CjMuRD/Esw8tVvx3IHE6bD5OkxHkKfnRSYgm17+UpX8JRMJ8zmr3ocNmxjodaItPjeCg n+IC7IVUVYO9eQ1YtsOu7c1z5V+1oLKyzENIgVNnxwTjIA6lmkUwtBYGrKrEQAJD1yia WrWQT6EhPSjh/zqsM7NH4LnujdVnJpK/wnl5Teh5o19c0C+LeAyOPkStsfTKG4kZ/MUK aBYTcd/psKruxAEy1/iolAqC7cLhPTMvl80ML7oDN99NMYQHJj9a3kkil3YCBXHkQgMC eHRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eMGmPaUj; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b4si1561533iln.32.2021.09.09.04.47.54; Thu, 09 Sep 2021 04:48: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=@kernel.org header.s=k20201202 header.b=eMGmPaUj; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236672AbhIILrR (ORCPT + 99 others); Thu, 9 Sep 2021 07:47:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:46458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240096AbhIILo3 (ORCPT ); Thu, 9 Sep 2021 07:44:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E605F611BD; Thu, 9 Sep 2021 11:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187751; bh=UZWytWGmXwex4+/1vb6H6PHBd6Zm9qo4AOXiHRecuTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eMGmPaUjg9Zrn+I63BEkTcfasCFlFL2lFEfc5T0SPv/8XrHiv2eJITmNkjjmJ6pCh BE8sB/ybN81HdGU5mkm5VP8ERvS+URvCwCwYIotsmvEcCEu9y4BMSFDURMAJmIc8Wi PzVq5FntYtY3xecUZBEgZKSybOTQ+Cyql08EwWhgzlXvl9o8OQuc1hdvtFgri7usPv 20fzt4LCZwZKCWQ02+L1oyT2Ssbg+cO1oCs/rreUhTx0TocfBw5XwoxuVgVOKTH7/z trcTcWowwGEXnOUIcq8j/yZ0E+9dzu5tJX3riNgAAVmho4JqxQbd8b/x28oDXm/PSn BN9z55bXeGlpQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Geert Uytterhoeven , Fabio Estevam , Laurent Pinchart , Sam Ravnborg , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.14 066/252] drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit Date: Thu, 9 Sep 2021 07:38:00 -0400 Message-Id: <20210909114106.141462-66-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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