Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aeefa1ec authored by Sergey Popovich's avatar Sergey Popovich Committed by David S. Miller
Browse files

ipv4: fib_semantics: increment fib_info_cnt after fib_info allocation



Increment fib_info_cnt in fib_create_info() right after successfuly
alllocating fib_info structure, overwise fib_metrics allocation failure
leads to fib_info_cnt incorrectly decremented in free_fib_info(), called
on error path from fib_create_info().

Signed-off-by: default avatarSergey Popovich <popovich_sergei@mail.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7fc1c5f3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -821,13 +821,13 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
	fi = kzalloc(sizeof(*fi)+nhs*sizeof(struct fib_nh), GFP_KERNEL);
	if (fi == NULL)
		goto failure;
	fib_info_cnt++;
	if (cfg->fc_mx) {
		fi->fib_metrics = kzalloc(sizeof(u32) * RTAX_MAX, GFP_KERNEL);
		if (!fi->fib_metrics)
			goto failure;
	} else
		fi->fib_metrics = (u32 *) dst_default_metrics;
	fib_info_cnt++;

	fi->fib_net = hold_net(net);
	fi->fib_protocol = cfg->fc_protocol;