From patchwork Thu Jan 18 12:33:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 189184 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp305925dyb; Thu, 18 Jan 2024 04:34:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHxEUJuTfVvg5o5JFpZzFeoZ8EynQXIm05Yto58+qwOQ13KeVXArygC7XK0VzUqb5qQK52I X-Received: by 2002:a05:6a00:4087:b0:6d9:8ccb:be1b with SMTP id bw7-20020a056a00408700b006d98ccbbe1bmr676460pfb.29.1705581256572; Thu, 18 Jan 2024 04:34:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705581256; cv=pass; d=google.com; s=arc-20160816; b=Qsu0J9Ccq77N8JB4j2IJJ+X/IufTvhhWDByl95cFxhY5gkJg0eJQpxO5q8f8VN3AR+ Cqgazf5RKqtNnP7lB3bZLC5ws428BG760sVlp/fU0xS9PovF2r/U5ieIqBvhfZ9zfoKz oGLvndfqci53j0PMQPcUWBc2KHghgAfmBkJhlkHAa+XR1cj730VWDC+IzhmSdL8COoHi wxSYMOhA7a8kirNRzYppJSpWEUu3FJR+GXJMe4XrtujFLEwK/duVQ+O3luFS5MHAkiSq /0uZC/gv58TheST1O3GEaI8J4QE0tKMdKdtFIaSHN5dL5XBf4GjVosim6IxHupO0TEot bPmg== 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 :dkim-signature:from; bh=8vg4TreMwHyQzz57ZlQq9JFOtxfPPCMiJHGivl59KOc=; fh=Ty0rbfPy1E0oAzlvrCk9QFh6+AMkEnH60XHUU7iSYug=; b=AJXwpHHz4e9OazRtiZ/ELXchiriJz3dPmusjU8iT7mTGxhSU/bF1xyvYiYzzzL3EZI J/lVjW3VOM8521/W44C3Zo9/AHx5OWiBKjo4Md9TZDu8U8gtptv5JO0uajwnLGTEHxyX ykTjB1EVIJqn+/lg61IroyjWlYTK/Nw70VqT5SspOro1LjuNCXQ3ztL3MlPFQxVqh/UK ciS3JSEZeuMa4praNs3/2oj5zgXn7Ry8mHhCQ3FRDWWVK6BTen/1zXpslifbxLKWSkyR Vd5H9OyZWNfhDKTp1S1oHoR20ON9H3PZExy+HPAr6WxFuKV4dPJa9KtoWS/nZZPg/s/2 SI2w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=CN++Aq9c; arc=pass (i=1 spf=pass spfdomain=swemel.ru dkim=pass dkdomain=swemel.ru dmarc=pass fromdomain=swemel.ru); spf=pass (google.com: domain of linux-kernel+bounces-30097-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30097-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g18-20020a631112000000b005cdfc019319si1334584pgl.751.2024.01.18.04.34.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jan 2024 04:34:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-30097-ouuuleilei=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; dkim=pass header.i=@swemel.ru header.s=mail header.b=CN++Aq9c; arc=pass (i=1 spf=pass spfdomain=swemel.ru dkim=pass dkdomain=swemel.ru dmarc=pass fromdomain=swemel.ru); spf=pass (google.com: domain of linux-kernel+bounces-30097-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-30097-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.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 43A06283368 for ; Thu, 18 Jan 2024 12:34:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 591A624B5F; Thu, 18 Jan 2024 12:34:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b="CN++Aq9c" Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CCC724B37; Thu, 18 Jan 2024 12:33:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.143.211.150 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705581240; cv=none; b=PrYhxwYctGedV58Qo4apnd+bjcn6wP/GRXP/+jXt4PWPYsui2rf1eKjiiaxEZarJsPS7+Z4qc7Ua8ywtAojwyb3pMnvQD2cIlPfHJFKWtG7Z5PTC5LDt20qXW9UXZ+IoUU1A7qM8skJ5xRzWBu47MSA4o1fKr/EEK/AAg3G0xLE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705581240; c=relaxed/simple; bh=enSOVsCGs4bxes4ItZtt6sN9rqkkFbugofi4iUTiV7o=; h=From:DKIM-Signature:To:Cc:Subject:Date:Message-Id:MIME-Version: Content-Transfer-Encoding; b=qfHlHCdi34I5PX9BpW5/464PctFbHKiNMrrS8W4r2npywMbdjwv7gau6BcXHV4EY5yae0papws1qtnuLyDfJljylWHWC1DDOsBa0NrTGyQyqebxzt3fp85LbmnELFgCnAubz1kIV9JYhgFRtNA4H2ENv9UX5UB2rOSKGQJozOdI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru; spf=pass smtp.mailfrom=swemel.ru; dkim=pass (1024-bit key) header.d=swemel.ru header.i=@swemel.ru header.b=CN++Aq9c; arc=none smtp.client-ip=95.143.211.150 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=swemel.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=swemel.ru From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1705581228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8vg4TreMwHyQzz57ZlQq9JFOtxfPPCMiJHGivl59KOc=; b=CN++Aq9cMKtmUorUWfJ1inQs3tM4qS9v46kSiGAkbVu9rR6Y9phUJL3hfEAHNX47CwRXZP FFr47QPeqZbmxFUtFavCQX+wIBnXIT7JsT6f8DTw27qdQX47H7O185rH0H7AOdz/8r9d5l v7XZEKwIkKBBlzjSe7/rTxGyPqDoGQw= To: Ian Abbott Cc: Greg Kroah-Hartman , H Hartley Sweeten , linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, "# v5 . 15+" Subject: [PATCH] comedi: drivers: ni_tio: Fix arithmetic expression overflow Date: Thu, 18 Jan 2024 15:33:48 +0300 Message-Id: <20240118123348.45690-1-arefev@swemel.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788431571720256559 X-GMAIL-MSGID: 1788431571720256559 The value of an arithmetic expression period_ns * 1000 is subject to overflow due to a failure to cast operands to a larger data type before performing arithmetic Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 3e90b1c7ebe9 ("staging: comedi: ni_tio: tidy up ni_tio_set_clock_src() and helpers") Reviewed-by: Ian Abbott Signed-off-by: Denis Arefev Signed-off-by: Ian Abbott --- drivers/comedi/drivers/ni_tio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/comedi/drivers/ni_tio.c b/drivers/comedi/drivers/ni_tio.c index da6826d77e60..acc914903c70 100644 --- a/drivers/comedi/drivers/ni_tio.c +++ b/drivers/comedi/drivers/ni_tio.c @@ -800,7 +800,7 @@ static int ni_tio_set_clock_src(struct ni_gpct *counter, GI_PRESCALE_X2(counter_dev->variant) | GI_PRESCALE_X8(counter_dev->variant), bits); } - counter->clock_period_ps = period_ns * 1000; + counter->clock_period_ps = period_ns * 1000UL; ni_tio_set_sync_mode(counter); return 0; }