Skip to content

Commit 2ce0205

Browse files
charleskeepaxgregkh
authored andcommitted
mfd: cs42l43: Sanity check firmware size
[ Upstream commit b6ef1a7 ] Currently the code checks if a firmware was received, however it does not verify that the firmware size is larger than the firmware header. As the firmware pointer is dereferenced as a pointer to the header structure this could lead to an out of bounds memory access. Add the missing check. Fixes: ace6d14 ("mfd: cs42l43: Add support for cs42l43 core driver") Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://patch.msgid.link/20260508134804.1787461-1-ckeepax@opensource.cirrus.com Signed-off-by: Lee Jones <lee@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7c3264d commit 2ce0205

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/mfd/cs42l43.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static void cs42l43_mcu_load_firmware(const struct firmware *firmware, void *con
666666
unsigned int loadaddr, val;
667667
int ret;
668668

669-
if (!firmware) {
669+
if (!firmware || firmware->size < sizeof(*hdr)) {
670670
dev_err(cs42l43->dev, "Failed to load firmware\n");
671671
cs42l43->firmware_error = -ENODEV;
672672
goto err;

0 commit comments

Comments
 (0)