From 484d349fe3e4ad35f9e53b56c8ba03e98ab8bc75 Mon Sep 17 00:00:00 2001 From: xucheng5 Date: Tue, 30 May 2023 11:49:03 +0800 Subject: [PATCH] driver/mtd : check args for nvs read mtd_config_fs: check configdata before use Signed-off-by: xucheng5 --- drivers/mtd/mtd_config_fs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/mtd_config_fs.c b/drivers/mtd/mtd_config_fs.c index 5e47147034..6c45c5af38 100644 --- a/drivers/mtd/mtd_config_fs.c +++ b/drivers/mtd/mtd_config_fs.c @@ -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