Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp550394lqi; Thu, 7 Mar 2024 05:20:46 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWb9d8CZE6WBIH4aMQ7CzLxr0/X04n2MITdFAIw8MQCMGgxqzbSsj/OkJfzVhVDDuhJbOi1duD3dnjG04Zi71FQyLH9J0gWoLCDMS7RgA== X-Google-Smtp-Source: AGHT+IHbb6NB1W/0qC8syHk3oueCFHyWptKSpaVp1/UqXzJlxvVW/GhcNjIgjmbMawlDPUtKjUDC X-Received: by 2002:a05:6a20:6a1c:b0:1a1:6f4f:d961 with SMTP id p28-20020a056a206a1c00b001a16f4fd961mr2359304pzk.16.1709817646077; Thu, 07 Mar 2024 05:20:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709817646; cv=pass; d=google.com; s=arc-20160816; b=VgQ5bxAOKMXM5TTRXvEExGFiiXK16fCq0HVbIzZH0PB9U6wmc4MiBKfjyr5xucl2lT 28ATRRpXSiVWMZP0J2rwMPTojXAxzAl2AODjC0Zbb7Afi3MgkODTEDDRQ/E/5jOPcumF cqYqYM8IrEmWyIHYJkrJ5bMJCy/Cl+HgTniYvQgXS76VAg2iSyyxkDoIJJt4zglfUGvn 7cR0SSVuCagZ7xHQcdvqrEkZQuseW0tBo2Pqb50W28ZavmisRnOy/wOVcrCrlnVMoAsq toit2v2OsglXD0Ql8rRVLxCcRm3FFVoIwgBnANmNIBkpPd7/Fryp1JwUGSdWa1PrlJg+ 9lag== 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=8ywLdskw4v4YI5injdY6pt+2ePv6lW18zQCm2RCrEZI=; fh=Hp9XB8aVl3SQWYTwVLoRYHsIgTsvekxxT0rj/G6n+HQ=; b=zLIbLHL99ErxNrMLFOhweSalljD7M7SSGD+0+n1ubLcgrkL0fvyGZUuDdf1uE7wPEi t1Q6TphkO1P/WaSpMJgjcZa9QhZOqf+eEgQTNzyB+mC+rTAL9ZT4RpZowecU2bmG4E6R xBtgN5mT0MXvX8KdvNqZ5+76MZcL0ScHvKhgl2Oa09NGbwxMhFgXkOFNEmsVZizh0fg+ ZN/DsGwqMi+Axh5nduk1nJbzHwANUSHfDBUVoCT2VMwxyqLRe61YC6hPTy3t0OmPSeY6 ZmzVVMWFWd1tG/5OzNdYVJGzsFzEy8nYH3aFRVEiEBSR4ITOk+G45FJhYDQWcuS+cdIV OxTA==; 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-95585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95585-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. [139.178.88.99]) by mx.google.com with ESMTPS id e9-20020aa798c9000000b006e45beffa25si13737047pfm.291.2024.03.07.05.20.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 05:20:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-95585-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95585-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 8CB85283893 for ; Thu, 7 Mar 2024 13:20:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8F1A512C7EB; Thu, 7 Mar 2024 13:20:36 +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 997EB12C52D; Thu, 7 Mar 2024 13:20:28 +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=1709817636; cv=none; b=MFneFFAtwAxX3ryjrUTBcjY3VyZJGk0XGwJHqC3rJUele1zr7+EMWG7gV3CQ6mkeUqjbQnojRzlYvb+kEHayZbeXWkTW9bfDYplhfZQmcxKMoOR6WabTZ7w6LiEnOu3aZ6/7IV5dpON1mEK4m+qwEGOdQomT9uTyZjPDkSkba8w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709817636; c=relaxed/simple; bh=p0S6TKLtZr54QKpjwWO7mH2N9msbPcid8zVNvisldXE=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=j/QyVidGnbu/NAODMMrdPMtv461xBJB2Kkre7LhEcJGNSK9xmSutcdPyBsP3m0aiWgIgWyyZm+fy4q0EdMmNBuHlPDMpZGqssKrTW31jSE8A24QuiBWnDjx2iEeAXukkFmHNXRC2q0rZVqr2cc8Uo46/RFCEDlolQE/49z8PN5c= 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: Doug Berger CC: Daniil Dulov , Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , Subject: [PATCH] net: phy: mdio-bcm-unimac: Cast denominator to unsigned long to avoid overflow Date: Thu, 7 Mar 2024 16:19:47 +0300 Message-ID: <20240307131947.13133-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-01.aladdin.ru (192.168.1.101) 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. Fixes: b78ac6ecd1b6 ("net: phy: mdio-bcm-unimac: Allow configuring MDIO clock divider") 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 68f8ee0ec8ba..055102e6bb6d 100644 --- a/drivers/net/mdio/mdio-bcm-unimac.c +++ b/drivers/net/mdio/mdio-bcm-unimac.c @@ -192,7 +192,7 @@ static void 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"); return; -- 2.25.1