mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-29 13:23:23 +01:00
nvmem: core: verify cell's raw_len
Check that the NVMEM cell's raw_len is a aligned to word_size. Otherwise Otherwise drivers might face incomplete read while accessing the last part of the NVMEM cell. Signed-off-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
1 parent
7a06ef7510
commit
13bcd440f2
1 file changed
+12
@@ -605,6 +605,18 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!IS_ALIGNED(cell->raw_len, nvmem->word_size)) {
|
||||
dev_err(&nvmem->dev,
|
||||
"cell %s raw len %zd unaligned to nvmem word size %d\n",
|
||||
cell->name ?: "<unknown>", cell->raw_len,
|
||||
nvmem->word_size);
|
||||
|
||||
if (info->raw_len)
|
||||
return -EINVAL;
|
||||
|
||||
cell->raw_len = ALIGN(cell->raw_len, nvmem->word_size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user