driver/mtd : check args for nvs read

mtd_config_fs: check configdata before use

Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
This commit is contained in:
xucheng5 2023-05-30 11:49:03 +08:00 committed by Xiang Xiao
parent 37cdfeed9b
commit 484d349fe3

View File

@ -1750,7 +1750,7 @@ static ssize_t nvs_read(FAR struct nvs_fs *fs,
uint8_t key[sizeof(pdata->id) + sizeof(pdata->instance)];
#endif
if (pdata == NULL || pdata->len == 0)
if (pdata == NULL || pdata->len == 0 || pdata->configdata == NULL)
{
return -EINVAL;
}
@ -1798,6 +1798,11 @@ static int nvs_next(FAR struct nvs_fs *fs,
struct nvs_ate step_ate;
uint32_t rd_addr;
if (pdata == NULL || pdata->len == 0 || pdata->configdata == NULL)
{
return -EINVAL;
}
#ifdef CONFIG_MTD_CONFIG_NAMED
FAR uint8_t *key = (FAR uint8_t *)pdata->name;
#else