linux/drivers/media/cec
Mauro Carvalho Chehab ba9cf6b430 media: pulse8-cec: fix data timestamp at pulse8_setup()
As pointed by Coverity, there is a hidden overflow condition there.
As date is signed and u8 is unsigned, doing:

	date = (data[0] << 24)

With a value bigger than 07f will make all upper bits of date
0xffffffff. This can be demonstrated with this small code:

<code>
typedef int64_t time64_t;
typedef uint8_t u8;

int main(void)
{
	u8 data[] = { 0xde ,0xad , 0xbe, 0xef };
	time64_t date;

	date = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
	printf("Invalid data = 0x%08lx\n", date);

	date = ((unsigned)data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
	printf("Expected data = 0x%08lx\n", date);

	return 0;
}
</code>

Fix it by converting the upper bit calculation to unsigned.

Fixes: cea28e7a55 ("media: pulse8-cec: reorganize function order")
Cc: stable@vger.kernel.org
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
2024-10-18 10:43:03 +02:00
..
core [tree-wide] finally take no_llseek out 2024-09-27 08:18:43 -07:00
i2c media: cec: ch7322: drop of_match_ptr for ID table 2023-07-14 12:31:12 +02:00
platform Mainly singleton patches, documented in their respective changelogs. 2024-05-19 14:02:03 -07:00
usb media: pulse8-cec: fix data timestamp at pulse8_setup() 2024-10-18 10:43:03 +02:00
Kconfig media: CEC: keep related menu entries together 2021-10-05 09:39:32 +02:00
Makefile media: cec: i2c: ch7322: Add ch7322 CEC controller driver 2020-07-04 12:16:18 +02:00