Re: [Linuxptp-devel] [PATCH RFC 1/7] rtnl: Fix rtnl_rtattr_parse() to process max attribute.
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Hangbin L. <liu...@gm...> - 2022-01-14 02:46:17
|
On Thu, Jan 13, 2022 at 04:54:54PM +0100, Miroslav Lichvar wrote: > 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 <mli...@re...> > Cc: Hangbin Liu <liu...@gm...> > --- > 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 > Acked-by: Hangbin Liu <liu...@gm...> |