Initialize the whole array passed to rtnl_rtattr_parse() and don't
ignore the last attribute with the maximum value. This will be needed to
get the ETHTOOL_A_PHC_VCLOCKS_INDEX attribute.

Signed-off-by: Miroslav Lichvar <[email protected]>
Cc: Hangbin Liu <[email protected]>
---
 rtnl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rtnl.c b/rtnl.c
index fe625d6..88a749f 100644
--- a/rtnl.c
+++ b/rtnl.c
@@ -178,10 +178,10 @@ static int rtnl_rtattr_parse(struct rtattr *tb[], int 
max, struct rtattr *rta, i
 {
        unsigned short type;
 
-       memset(tb, 0, sizeof(struct rtattr *) * max);
+       memset(tb, 0, sizeof(struct rtattr *) * (max + 1));
        while (RTA_OK(rta, len)) {
                type = rta->rta_type;
-               if ((type < max) && (!tb[type]))
+               if ((type <= max) && (!tb[type]))
                        tb[type] = rta;
                rta = RTA_NEXT(rta, len);
        }
-- 
2.33.1



_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to