Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp1277713rbe; Fri, 1 Mar 2024 09:11:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQMLeWdn36+3hNsMaA+JwS1yX8MzOIJFygdfnvIxE+9dtW0ufAFMyhqLfMhcDqtHodAcPOFzir9fHsYQPkJSjZX3GoVctc+bH+SZ8yHg== X-Google-Smtp-Source: AGHT+IGrpdsSW6/It2WZLDDQmgxKuwVQW/dffO0LKf+xKeRAzjaNFD6tvxh448pHpR2H7wEuBvfj X-Received: by 2002:a17:906:16d6:b0:a44:98dd:a30c with SMTP id t22-20020a17090616d600b00a4498dda30cmr1365089ejd.64.1709313079095; Fri, 01 Mar 2024 09:11:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709313079; cv=pass; d=google.com; s=arc-20160816; b=XT3HtH7UbuUSAWgIT1qiMjRWI7+qGTzg7EOtAKOa3Ymh/ptBTyejtcvtdYbWR6aEF+ 5FMDgh0dP9u5uAa6WNBPPYIrG35aXjLZh8nHbTmlnPTqK0oDUEBV0EuUMTK9kKCJmLW/ AYbpMhCAZNPCfDNYSih9YdXTcvdK/Kh+cJot+w1rGOsCghbJ8KrRudnwkZs3TWV3wtDO 3OTpuUbB8y5z/hjEI5c/0mTWpz2c2J22c+UpVtrcMDCRb38liTx1/lBUHYd19b19YYO8 aNvXPOBj3D5ihqWfaWaN00UL2YxzcAbiB8BONC8ONcY817nKDiJnx3+FsNP547kHRatn TVYQ== 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:dkim-signature:dkim-filter; bh=a6DlMHYD50bgw5c8dbRDQuJSmrsCV4dJRNHYFXyLCp8=; fh=heUQflzKV2l7WUj9SfCW1UtCklZQgaXhhfasJn/9zKs=; b=flRqwfHksCHkRQIUBFTI4RyoLu/4kAUxNXAme8aCIxTjrVkEhPVYcnPmYQD8KpE1or tStThFDI5uc8buOVJWb/Wnn3cz5xZWyXnl7FH+qQrLDK4JIvCqdCQVRDnOZ2L0Kum8uB Mlx58KbySdc0GOx17EO3hJBRsrXudzrBn7zPt3/hMErsijmYmLd+J9lkMbJj3UrocUos FX7QdjhO6btL4Ip4ovKUn8MTA2GmHrGYjz6FTAmUmb3rb6cOknKYg/lUnCdZ0CbvjOkb 0h/lAtY5o/LhVJDOcc8nOapunikwe40YU2Gs33kpz3JoW19UrU/M8rNRDI/VUMET2VYF qJ3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=WZJOx2BE; arc=pass (i=1 spf=pass spfdomain=rosalinux.ru dkim=pass dkdomain=rosalinux.ru dmarc=pass fromdomain=rosalinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-88810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.ru Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t7-20020a170906a10700b00a4372e67791si1618187ejy.991.2024.03.01.09.11.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:11:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rosalinux.ru header.s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503 header.b=WZJOx2BE; arc=pass (i=1 spf=pass spfdomain=rosalinux.ru dkim=pass dkdomain=rosalinux.ru dmarc=pass fromdomain=rosalinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-88810-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88810-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rosalinux.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 am.mirrors.kernel.org (Postfix) with ESMTPS id D5E061F22831 for ; Fri, 1 Mar 2024 17:11:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43EC58832; Fri, 1 Mar 2024 17:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b="WZJOx2BE" Received: from mail.rosalinux.ru (mail.rosalinux.ru [195.19.76.54]) (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 3ED37F503; Fri, 1 Mar 2024 17:10:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.19.76.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709313045; cv=none; b=QfvR308ofjPc91HwYwSMN3PFOPSw8S57qvDSxEvuUUdKA4rjD/qLk0YuAHKzjCklXNtIPF/wZBpSfRabnk3wkQW270nrIxjWqCZFUkbtqd6aDzqOopnFiQ2Cq0eg8/4Tl5NIO2baeOQZsGiWyfWWBCWylmv1F2nu44D3mMhpw/U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709313045; c=relaxed/simple; bh=1f3lWg+pkiYMDBEYhxFCMSCS17hH2ui9obrcK7tKVE8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=m4BHJV8ECaAS5cBzBk2LuUBv6PZPwpSF2vNsnW+pnAdlw6JT6Yv3/Ap2x25l/lPjJn6A6Ouv9IsQxCmKf7/IVeP5Ietup7S2SLLGc/RNVOIiQV5y2pJClYoe4/cNwKRpTmdodkOUgteqoSwMzdWfe8shtOAwlHDOylqqan1L+Sk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=rosalinux.ru; spf=pass smtp.mailfrom=rosalinux.ru; dkim=pass (2048-bit key) header.d=rosalinux.ru header.i=@rosalinux.ru header.b=WZJOx2BE; arc=none smtp.client-ip=195.19.76.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=rosalinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rosalinux.ru Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id B0641DD7B446E; Fri, 1 Mar 2024 20:10:29 +0300 (MSK) Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 9K59O71FHrtq; Fri, 1 Mar 2024 20:10:29 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.rosalinux.ru (Postfix) with ESMTP id 7CD77DD7B4472; Fri, 1 Mar 2024 20:10:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.rosalinux.ru 7CD77DD7B4472 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rosalinux.ru; s=1D4BB666-A0F1-11EB-A1A2-F53579C7F503; t=1709313029; bh=a6DlMHYD50bgw5c8dbRDQuJSmrsCV4dJRNHYFXyLCp8=; h=From:To:Date:Message-ID:MIME-Version; b=WZJOx2BE56ZBTHhYS4Gdw6s8fbuKRWxiG9rvR0s32OSNIiJ8FmqPE0Z9GFqpMBTxV C6OPEUJacpxpp2sgO/cCck0BPtzeX1pc/yh86Tg0Pz7tNk3/JRMwkZtnRGJU90J+iH Pyo4cdUx+fFgUYBVWbEcoFSaCuHDyyXGuxwFZmtI00G0VtefyqpImFc8sZrMyMBkbE dLsnyiXdbhVvH4fBANj+L5AzSJIkulOi5gTXysXVZ83PRsvYqGHggmQuKGibMkdGrO Bh/1VU9M9rac7U5h2ti8+QotSQOkh0LmEW30NuwEx0fuTUf9UEkHc6Lz2R6c7buGqU 9x+noiYVLTn0w== X-Virus-Scanned: amavisd-new at rosalinux.ru Received: from mail.rosalinux.ru ([127.0.0.1]) by localhost (mail.rosalinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 6DYsYvXOHtQm; Fri, 1 Mar 2024 20:10:29 +0300 (MSK) Received: from localhost.localdomain (unknown [62.217.186.174]) by mail.rosalinux.ru (Postfix) with ESMTPSA id 4C10ADD7B446E; Fri, 1 Mar 2024 20:10:29 +0300 (MSK) From: Mikhail Lobanov To: Mauro Carvalho Chehab Cc: Mikhail Lobanov , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] media: v4l2-tpg: Fix division by zero error in color_to_hsv Date: Fri, 1 Mar 2024 12:08:36 -0500 Message-ID: <20240301170838.57421-1-m.lobanov@rosalinux.ru> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In the color_to_hsv function, division by zero is possible due to attributes r,g,b are equal so diff_rgb =3D 0. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 54fb15348385 ("[media] vivid: Add support for HSV formats") Signed-off-by: Mikhail Lobanov --- drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/medi= a/common/v4l2-tpg/v4l2-tpg-core.c index a366566f22c3..943aab3ad97c 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c @@ -597,6 +597,11 @@ static void color_to_hsv(struct tpg_data *tpg, int r= , int g, int b, third =3D third_size * 2; } =20 + if (!diff_rgb) { + *s =3D 0; + return; + } + aux *=3D third_size / 2; aux +=3D diff_rgb / 2; aux /=3D diff_rgb; --=20 2.39.2