From 23d42632079cc8e5671b7cdceba874091172bebc Mon Sep 17 00:00:00 2001 From: xucheng5 Date: Wed, 12 Jul 2023 14:51:18 +0800 Subject: [PATCH] driver/mtd_config: just query when data is null or len is zero Signed-off-by: xucheng5 --- drivers/mtd/mtd_config.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/mtd_config.c b/drivers/mtd/mtd_config.c index d089758690..fe20a0c323 100644 --- a/drivers/mtd/mtd_config.c +++ b/drivers/mtd/mtd_config.c @@ -1423,14 +1423,17 @@ static int mtdconfig_getconfig(FAR struct mtdconfig_struct_s *dev, /* Perform the read */ - ret = mtdconfig_readbytes(dev, offset + sizeof(hdr), pdata->configdata, - bytes_to_read); - if (ret != OK) + if (pdata->configdata && bytes_to_read) { - /* Error reading the data */ + ret = mtdconfig_readbytes(dev, offset + sizeof(hdr), + pdata->configdata, bytes_to_read); + if (ret != OK) + { + /* Error reading the data */ - ret = -EIO; - goto errout; + ret = -EIO; + goto errout; + } } /* Set return data length to match the config item length */