From patchwork Mon Jan 13 13:53:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 856923 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1434546wrc; Mon, 13 Jan 2025 05:55:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUJ2rYAebGnWDsT1OkLMxhqE/F6G2pZzmqxIJBZW8NuFJaNHmtLdOwarA5PLuhLJsUpiQWt+A==@linaro.org X-Google-Smtp-Source: AGHT+IEAAmf8kp3PTsvHV6qU9mRz3/lAMZ+aLX3s9VDBbWk7+CkSCueJSb3kDKPkrwWVCp7VH1C1 X-Received: by 2002:ac8:5fd2:0:b0:467:81f0:6d63 with SMTP id d75a77b69052e-46c71003325mr329326991cf.17.1736776536693; Mon, 13 Jan 2025 05:55:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736776536; cv=none; d=google.com; s=arc-20240605; b=a/uSZcS7G8d4c3KxaIZZDgBr5Dg8WR+Yu+f9rmL74Z3OCbj/fse1uqrJb5xDiyEhOV gyhw+UBBPVG8kBxiGsz/bCCKdxBqNcdHHDHOLNSDPgoDbuJ2xTO7uiuExb5/d2/YNeBF uXgnwyDdleaT/b9SYzzjubKM8XGi4iunlt/gEeIIT6612L9lG/Bn+tcK61JJrmFrkvYU JMF9IVvBCZfKz1v5RCiZXirgn8hbPALRWzsZZ/geqSJJ5zLmszdex47g/IC7Llb9blIr 5M0fsDKSAIYqe5Azwl4k+NEpWuVr1ApxWa+K0lU0aF/E3SSnjwK264SOrOVlLNyuv+/j 5YcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=HQO9GVDNQTUiwYqISYlU2glyJAveShyUsrRw4PZ/cEo=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=ktw+N64e+suY/sb2G9JV5UZQ2hlDMK5cRSHwCO8mtZsyGw5He6T+X8a4mhz7fptGo4 tUirbSL7TU5Fc+NFQfl+VWNDCcyGV3CKcbGW2/N8pT+1H7EX/n6WkYj7unuxRyDbTxaF S8lYh6R7joUBXvbW54qD27TU+JynsYOEyXQUzSUFDrHqIc6LGbcTpyUsTmi83Q6i0JeU /y2ztA/pvFXcReOiaehT8Z7Y7DR+JlPQT2AIyUzfAuW418N2xizQoF+TnoTOW0dLjRQ8 +xW0jLoHubeqRZv3KckzylF8ON/9npitYrEErpycFi1BmFrUxeanWVaIIB5ZldJ9asLM EMhA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ihP0b7lE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46c8735217asi93657631cf.198.2025.01.13.05.55.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 13 Jan 2025 05:55:36 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ihP0b7lE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tXKtz-0005bZ-KR; Mon, 13 Jan 2025 08:54:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tXKtV-0005Xm-Qz for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:54:17 -0500 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXKtT-0007eN-4c for qemu-devel@nongnu.org; Mon, 13 Jan 2025 08:54:17 -0500 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-43635796b48so26700595e9.0 for ; Mon, 13 Jan 2025 05:54:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736776452; x=1737381252; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HQO9GVDNQTUiwYqISYlU2glyJAveShyUsrRw4PZ/cEo=; b=ihP0b7lEsjxV3tNCHccIMLVLvv+XSXdEFdOb1R8izqHeRlYcTtzJNzHzAQ6SAVawMU pWFCf8PsL2nCFwonOOovArpA4px2fCbBDnhPyNFmV6nh0GJ5Hi8+YFCFJ8xN5IJMuqVe IqiRJRc6ProPIKpydzEeODeUpTehVMV0mCUqh+VUTPhn4B5E80RE7u3Yhm0iuzS6cMCO ylOMeXZYw1fYSHqnFejsmMUvVIC/5Re3va96fD3ZV/yP8zTsLIAjDVMu2q4a0ShrQdZV 9N8maB/7ToawZQ6GB3gWBQyM/Z/cK2gmF68JChJWW6IWsNr1KbCquQoC2cQudgUUkuIJ JD3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736776452; x=1737381252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HQO9GVDNQTUiwYqISYlU2glyJAveShyUsrRw4PZ/cEo=; b=BCEszIVWPyhXDkUQFqKb/Um07UvP6/fGed4Zg5Pe1GVpIznbc+Uyd7JNOGPTlq1HZE kzQKRSM0Bai+pfAdb6fTgbMSClgqDEp7Y1hn8My0haA2kJwDG/ZSALMRC3+OvYu8Laxq CXfGXGyTGE1qDmYYy8PKGQXuqBPXWeVQ5EFQw0DXQigs4taRcnC7DnmS7Jl6jo5IbLrW DP3x+Pubf7qDuhbOXnhPDgCu1CPxE3d2LsoaE1tuzZqIshlz4JtGE2z1XJhlKofkodt+ /Qx9EMtRZZi3dHxTYwOlO2DGgl+UbqZCMNbdlUonn4avf+teDw8qmePVUv2sDiFyzKMr nbiw== X-Gm-Message-State: AOJu0YxssJ/DDJ4tNE3M+n/beF4OpdIXMhc/wDd7tohQlK3FgN32LNfu ZVKPmPoaiwwqXGNjD1TYG3fH22OEX/9OVTZYRZ84PccukrOkVa4cMBe/eem6NtVFMQb2kYyJGJ4 3 X-Gm-Gg: ASbGnctg6eoAmrmiya52IlerAG2RDs2CXXFKjXe3twbj7kjiFN2Vkr5pvWbgSxsyErF piXRag9RiciPx+TWMbPg2xAO/egBFjdUZRNQYuMdxFd5HJeS4+BqS0wX8KXfKS0jk/e7aREfaXh kyL1i3no1GvNd8fwWwt0iCsHQECAJGjjTO0do1vdCKntSqpGigJGFnNOKbECYAbT27q4a3E/7n6 +4XVKcE1rleEp11alkI5TAonm156/3ihumpn1kbuGPzl21YRGv3Yz6oB73xUtE= X-Received: by 2002:a05:600c:1e1f:b0:436:fdac:26eb with SMTP id 5b1f17b1804b1-436fdac27d7mr20551835e9.7.1736776452409; Mon, 13 Jan 2025 05:54:12 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e9d8fba4sm145245205e9.4.2025.01.13.05.54.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jan 2025 05:54:11 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 02/11] hw/misc: cast rpm to uint64_t Date: Mon, 13 Jan 2025 13:53:59 +0000 Message-Id: <20250113135408.3164401-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250113135408.3164401-1-peter.maydell@linaro.org> References: <20250113135408.3164401-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Tigran Sogomonian The value of an arithmetic expression 'rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION' is a subject to overflow because its operands are not cast to a larger data type before performing arithmetic. Thus, need to cast rpm to uint64_t. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Tigran Sogomonian Reviewed-by: Patrick Leis Reviewed-by: Hao Wu Message-id: 20241226130311.1349-1-tsogomonian@astralinux.ru Signed-off-by: Peter Maydell --- hw/misc/npcm7xx_mft.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/misc/npcm7xx_mft.c b/hw/misc/npcm7xx_mft.c index 9fcc69fe5c5..e565cac05d8 100644 --- a/hw/misc/npcm7xx_mft.c +++ b/hw/misc/npcm7xx_mft.c @@ -172,8 +172,9 @@ static NPCM7xxMFTCaptureState npcm7xx_mft_compute_cnt( * RPM = revolution/min. The time for one revlution (in ns) is * MINUTE_TO_NANOSECOND / RPM. */ - count = clock_ns_to_ticks(clock, (60 * NANOSECONDS_PER_SECOND) / - (rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION)); + count = clock_ns_to_ticks(clock, + (uint64_t)(60 * NANOSECONDS_PER_SECOND) / + ((uint64_t)rpm * NPCM7XX_MFT_PULSE_PER_REVOLUTION)); } if (count > NPCM7XX_MFT_MAX_CNT) {