Skip to content

Commit

Permalink
Null check before freeing stats memory
Browse files Browse the repository at this point in the history
While doing the module cleanup, incase of module init, the stats
memory needs to be cleaned up only it is already allocated. Accessing it
without validating it is allocated or not, leads to crash.
closes-bug: #1475558

Change-Id: Iaf0d67014174506d51bd9a46671e64d463d0db71
  • Loading branch information
divakardhar committed Aug 3, 2015
1 parent 13ed9d0 commit 0750d41
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dp-core/vr_ip_mtrie.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,9 @@ mtrie_stats_cleanup(struct vr_rtable *rtable, bool soft_reset)
{
unsigned int i, stats_memory_size;

if (!mtrie_vrf_stats)
return;

stats_memory_size = sizeof(struct vr_vrf_stats) * vr_num_cpus;
for (i = 0; i < rtable->algo_max_vrfs; i++) {
if (mtrie_vrf_stats[i]) {
Expand Down

0 comments on commit 0750d41

Please sign in to comment.