You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/04/19 11:53:56 UTC
[incubator-nuttx-apps] branch master updated: system/i2c: Fix fd leak in i2ccmd_reset
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 768a21b58 system/i2c: Fix fd leak in i2ccmd_reset
768a21b58 is described below
commit 768a21b587b4ea66b6e3452605673dd862994cbd
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Tue Apr 19 16:32:50 2022 +0800
system/i2c: Fix fd leak in i2ccmd_reset
Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
system/i2c/i2c_reset.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/system/i2c/i2c_reset.c b/system/i2c/i2c_reset.c
index 3e29c20f6..2809b06d2 100644
--- a/system/i2c/i2c_reset.c
+++ b/system/i2c/i2c_reset.c
@@ -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;
}