From patchwork Mon Feb 5 15:23:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 770747 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) (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 872022C85C; Mon, 5 Feb 2024 15:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.74.38.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707146684; cv=none; b=pB1/9jwwVUJSQOVdP/a1k3KaBKRCWgn9xY4AEPwb2/+tGPBjMGXUyzuxOmc83KiQVtwjyOFa03lH0fbyxM8rEKf0xhBMR8L889cyKY3HgCOdrnNNdqTrtEC/dC5QQ2CiKzZ3p8FonCq3IiuH0OEPGwyPh3KnFC3plPd/TpKOpys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707146684; c=relaxed/simple; bh=fEE6msD4XdTRoTXofN5+urjqqiYv6m5CX0D62N32MYg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=FJ5uaGIeU2pE3AzMKIaFv+wOO2xo6PWun6BRqq6/rPhmvgdT5Mb38yZAzEwwX9d/EmeYQWJ05rSe9f/8q+Mvf2j+G3onwultatKSfsDR7+/vnbq6aiTEABRDaUiIzPvK15LDJeNBzQgGPtGz1PjSxNl7DdGQDEFjMQhL/6IJkJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; arc=none smtp.client-ip=217.74.38.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 2E9C31865695; Mon, 5 Feb 2024 18:24:31 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VQTBXYzT9CdU; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id CC8F1186563B; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kfOHWGwef5L5; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.58]) by mail.astralinux.ru (Postfix) with ESMTPSA id 1C40A18639A5; Mon, 5 Feb 2024 18:24:30 +0300 (MSK) From: Anastasia Belova To: Philipp Zabel Cc: Anastasia Belova , Mauro Carvalho Chehab , Kamil Debski , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] media: coda: cast an operand of multiplication to a larger type Date: Mon, 5 Feb 2024 18:23:50 +0300 Message-Id: <20240205152350.22547-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If width and height are 0xffff (or close), the result of multiplication overflow. Add casting to a larger type to avoid undefined behavior. Such values are possible in CODA7, but unlikely. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 918c66fd4126 ("[media] coda: add CODA7541 decoding support") Signed-off-by: Anastasia Belova --- drivers/media/platform/chips-media/coda/coda-bit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/chips-media/coda/coda-bit.c b/drivers/media/platform/chips-media/coda/coda-bit.c index ed47d5bd8d61..84ded154adfe 100644 --- a/drivers/media/platform/chips-media/coda/coda-bit.c +++ b/drivers/media/platform/chips-media/coda/coda-bit.c @@ -585,7 +585,7 @@ static int coda_alloc_context_buffers(struct coda_ctx *ctx, if (!ctx->slicebuf.vaddr && q_data->fourcc == V4L2_PIX_FMT_H264) { /* worst case slice size */ - size = (DIV_ROUND_UP(q_data->rect.width, 16) * + size = (unsigned long)(DIV_ROUND_UP(q_data->rect.width, 16) * DIV_ROUND_UP(q_data->rect.height, 16)) * 3200 / 8 + 512; ret = coda_alloc_context_buf(ctx, &ctx->slicebuf, size, "slicebuf");