driver/mtd_config: just query when data is null or len is zero
Signed-off-by: xucheng5 <xucheng5@xiaomi.com>
This commit is contained in:
parent
da9b05cc33
commit
23d4263207
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue