Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1198994lql; Tue, 12 Mar 2024 09:55:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBs4fsSGjV16zp4xN3kiy4Coxt7sEsTMljtYmgPTEYFbW6er9g9jxitUKA5rkMB3EPtl+Anfoguqgc0i0b0cPrRDoLd2gZfd0xf/TmEQ== X-Google-Smtp-Source: AGHT+IE5rihL7vUiajnVzwS2k39BtstvuiObe7c8AmwGKjcWd/bX4HEPUCJbxZDtC4CjmtOeuscx X-Received: by 2002:a05:6358:5482:b0:17e:6dd9:d7d1 with SMTP id v2-20020a056358548200b0017e6dd9d7d1mr1915511rwe.31.1710262514031; Tue, 12 Mar 2024 09:55:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710262513; cv=pass; d=google.com; s=arc-20160816; b=tsA3gaPhillMypE+yQgJMhZwIBjJavZAjBHoivag3zhUwEv0dXGWRiD9M0J5R8nCqy DYoFU7DSAIa1z/PU8pMwQcKgZzy8eitRvnmUNtp+mvBj2VaA2PVZYLMSiih28VASKWOj wWzxKf1EAqTiHQkB9pu06BYGHH5fe+vjOhJKsGlvBt5ZN+79E4SV/Ix1aRfP5Vfe4XL9 JESPws+hVYQ63puGIfyYbDpd6HhfWfUpMMFbDoHH9LsJbF5209YbDfrr3acN4908EwZJ qxX2u1o220Qm4uNhUhj5Weh+Sdlwxx7tqN+bsgXm0e8dpsoBnpNDj3m23W65b5K+XHI7 mdiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=PV+WWWq8JzhIV/i72daobKuBNEgKUyv3UYp+FfIky5A=; fh=6SAXIG/dki60InEed2L7GGOFagsHdHkYpKKTGVRN/CM=; b=Zr+Oa12G81y+DI6HfsmYZZlm697cLLT1FqHJFigsDu8u6/prSYUBOlmocNoovOx65Y kB+Xpn5rOlliN56p+W0d5JNoMWKcz4DgP6yoTbeGXjJRSyGMFqE5sSBgfhUf8symDWhb dmQaJBhs5llJ5X8HD4YtkmRfgr1gK4513o1UywJofmzIzRuFFHQ2sJnfLai90TM7e237 bk5snsx8WtIFkcwDNR34+M17oKKMGTdKecCJ5qx5snbkCE/UhrfOjv6bGg08+nYPYaAX aaUORNlo4C61+A+rODezkBTAEFJ+jQR3PDfIs2SUGnW0WWHVsHabsg4OG6Vat05D/yO1 9TDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aladdin.ru dmarc=pass fromdomain=aladdin.ru); spf=pass (google.com: domain of linux-kernel+bounces-100549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aladdin.ru Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id k3-20020a63ba03000000b005e430f68ae4si7467840pgf.549.2024.03.12.09.55.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 09:55:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aladdin.ru dmarc=pass fromdomain=aladdin.ru); spf=pass (google.com: domain of linux-kernel+bounces-100549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aladdin.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 7EA86283E52 for ; Tue, 12 Mar 2024 16:55:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 28548137C27; Tue, 12 Mar 2024 16:54:51 +0000 (UTC) Received: from mail-out.aladdin-rd.ru (mail-out.aladdin-rd.ru [91.199.251.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DED68137C22; Tue, 12 Mar 2024 16:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.199.251.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710262490; cv=none; b=YwLSEYsLZ9SIPAfQCAhyMySTKnQgJ83ghUctbtvLAxfgiHcyuje8FmT9Af6tIu+4JAGpAZI5m5PnFFW2bnKgGI96RQxPKIqN8xoVvU466F2BEl1jUjqNTPrCmulVCFazaI6VwdwTW5COhJ8eshZ/45eCVS23YgqvJVrplm/xod8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710262490; c=relaxed/simple; bh=IatuUoyah9BqPO/PBrdSSVVhJx3+CGn5xo0Pwxl1H+o=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=nlAgdkfUWGIt7m7oF61pl4TkH/t2IJl4iuQWQZdWN6xbLh3Fv6XATUJ69dn75KWv+y1AtfOTgNTG4y9VKfTiSDGdfj1qmRSJY14TFc+85E0ofGqR9mOwM4GhsJK6RyJXSfT6X35QtgtpNWKaRfV1sWVZ7y7fRgp/+ZYpuFT6aAk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=aladdin.ru; spf=pass smtp.mailfrom=aladdin.ru; arc=none smtp.client-ip=91.199.251.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=aladdin.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aladdin.ru From: Daniil Dulov To: Jakub Kicinski , Florian Fainelli CC: Daniil Dulov , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Doug Berger , Paolo Abeni , , , Subject: [PATCH net-next] net: phy: mdio-bcm-unimac: Cast denominator to unsigned long to avoid overflow Date: Tue, 12 Mar 2024 19:53:58 +0300 Message-ID: <20240312165358.7712-1-d.dulov@aladdin.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EXCH-2016-02.aladdin.ru (192.168.1.102) To EXCH-2016-01.aladdin.ru (192.168.1.101) The expression priv->clk_freq * 2 can lead to overflow that will cause a division by zero. So, let's cast it to unsigned long to avoid it. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Daniil Dulov --- drivers/net/mdio/mdio-bcm-unimac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c index f40eb50bb978..0425b622c09f 100644 --- a/drivers/net/mdio/mdio-bcm-unimac.c +++ b/drivers/net/mdio/mdio-bcm-unimac.c @@ -214,7 +214,7 @@ static int unimac_mdio_clk_set(struct unimac_mdio_priv *priv) else rate = clk_get_rate(priv->clk); - div = (rate / (2 * priv->clk_freq)) - 1; + div = (rate / (2 * (unsigned long)priv->clk_freq)) - 1; if (div & ~MDIO_CLK_DIV_MASK) { pr_warn("Incorrect MDIO clock frequency, ignoring\n"); ret = 0; -- 2.25.1