system/i2c: Fix fd leak in i2ccmd_reset

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
This commit is contained in:
Huang Qi 2022-04-19 16:32:50 +08:00 committed by Petro Karashchenko
parent c7413ee859
commit 768a21b587

View File

@ -24,6 +24,8 @@
#include <nuttx/config.h>
#include <unistd.h>
#include <nuttx/i2c/i2c_master.h>
#include "i2ctool.h"
@ -60,6 +62,12 @@ int i2ccmd_reset(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
i2ctool_printf(i2ctool, "Failed to send the reset command\n");
}
ret = close(fd);
if (ret < 0)
{
i2ctool_printf(i2ctool, "Failed to close i2c device\n");
}
return ret;
}