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 <[email protected]>
---
v1->v2: patch is new
v2->v3: reverse patch order
util.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/util.c b/util.c
index cc4f11008be2..50f963bf915a 100644
--- a/util.c
+++ b/util.c
@@ -218,7 +218,8 @@ clockid_t posix_clock_open(const char *device, int
*phc_index)
fprintf(stderr,
"failed to parse PHC index from %s\n",
device);
- return -1;
+ phc_close(clkid);
+ return CLOCK_INVALID;
}
}
return clkid;
--
2.25.1
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel