When we determine that the "device" argument represents a path to a char
device, we call phc_open() and then we attempt to see, if the device
real path starts with "/dev/ptp", what number comes afterwards. If that
fails, we should close the char device we've just opened.

Fixes: 380d023abb1f ("posix_clock_open: derive PHC index from device name if 
possible")
Signed-off-by: Vladimir Oltean <olte...@gmail.com>
---
 util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util.c b/util.c
index 686ed5e2f110..34b0bc8e109c 100644
--- a/util.c
+++ b/util.c
@@ -226,7 +226,8 @@ clockid_t posix_clock_open(const char *device, int 
*phc_index)
                                fprintf(stderr,
                                        "failed to parse PHC index from %s\n",
                                        phc_device_path);
-                               return -1;
+                               phc_close(clkid);
+                               return CLOCK_INVALID;
                        }
                }
                return clkid;
-- 
2.25.1



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to