Fix parse_rtattr() does not completely initialize

Because max is the index of the last element in array tb, max+1
elements need to be initialized.

Signed-off-by: Leo Ruan <tingquan.ruan@cn.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
pull/106/head^2
Leo Ruan 2018-08-04 20:07:40 +02:00 committed by Marc Kleine-Budde
parent 4ea9ec7cf3
commit f5392c3654
1 changed files with 9 additions and 1 deletions

View File

@ -74,10 +74,18 @@ struct req_info {
struct can_bittiming *bittiming; struct can_bittiming *bittiming;
}; };
/**
* @brief this method parse attributions of link info
*
* @param tb: point array of struct rtattr point
* @param max: index of the last element in array tb
* @param rtattr: point of link info data
* @param len: length of link info data
*/
static void static void
parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta, int len) parse_rtattr(struct rtattr **tb, int max, struct rtattr *rta, int len)
{ {
memset(tb, 0, sizeof(*tb) * max); memset(tb, 0, sizeof(*tb) * (max + 1));
while (RTA_OK(rta, len)) { while (RTA_OK(rta, len)) {
if (rta->rta_type <= max) { if (rta->rta_type <= max) {
tb[rta->rta_type] = rta; tb[rta->rta_type] = rta;