drm/amd/display: fix memory leaks
Signed-off-by: Anthony Koo <Anthony.Koo@amd.com> Reviewed-by: Tony Cheng <Tony.Cheng@amd.com> Acked-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
f0cd0a346d
commit
9fcab85c58
@ -115,12 +115,12 @@ struct mod_stats *mod_stats_create(struct dc *dc)
|
|||||||
unsigned int reg_data;
|
unsigned int reg_data;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
if (dc == NULL)
|
||||||
|
goto fail_construct;
|
||||||
|
|
||||||
core_stats = kzalloc(sizeof(struct core_stats), GFP_KERNEL);
|
core_stats = kzalloc(sizeof(struct core_stats), GFP_KERNEL);
|
||||||
|
|
||||||
if (core_stats == NULL)
|
if (core_stats == NULL)
|
||||||
goto fail_alloc_context;
|
|
||||||
|
|
||||||
if (dc == NULL)
|
|
||||||
goto fail_construct;
|
goto fail_construct;
|
||||||
|
|
||||||
core_stats->dc = dc;
|
core_stats->dc = dc;
|
||||||
@ -146,6 +146,8 @@ struct mod_stats *mod_stats_create(struct dc *dc)
|
|||||||
core_stats->entries,
|
core_stats->entries,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
|
||||||
|
if (core_stats->time == NULL)
|
||||||
|
goto fail_construct_time;
|
||||||
|
|
||||||
core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT;
|
core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT;
|
||||||
core_stats->events = kzalloc(
|
core_stats->events = kzalloc(
|
||||||
@ -153,13 +155,13 @@ struct mod_stats *mod_stats_create(struct dc *dc)
|
|||||||
core_stats->event_entries,
|
core_stats->event_entries,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
|
||||||
|
if (core_stats->events == NULL)
|
||||||
|
goto fail_construct_events;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
core_stats->entries = 0;
|
core_stats->entries = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (core_stats->time == NULL)
|
|
||||||
goto fail_construct;
|
|
||||||
|
|
||||||
/* Purposely leave index 0 unused so we don't need special logic to
|
/* Purposely leave index 0 unused so we don't need special logic to
|
||||||
* handle calculation cases that depend on previous flip data.
|
* handle calculation cases that depend on previous flip data.
|
||||||
*/
|
*/
|
||||||
@ -171,10 +173,13 @@ struct mod_stats *mod_stats_create(struct dc *dc)
|
|||||||
|
|
||||||
return &core_stats->public;
|
return &core_stats->public;
|
||||||
|
|
||||||
fail_construct:
|
fail_construct_events:
|
||||||
|
kfree(core_stats->time);
|
||||||
|
|
||||||
|
fail_construct_time:
|
||||||
kfree(core_stats);
|
kfree(core_stats);
|
||||||
|
|
||||||
fail_alloc_context:
|
fail_construct:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,6 +191,9 @@ void mod_stats_destroy(struct mod_stats *mod_stats)
|
|||||||
if (core_stats->time != NULL)
|
if (core_stats->time != NULL)
|
||||||
kfree(core_stats->time);
|
kfree(core_stats->time);
|
||||||
|
|
||||||
|
if (core_stats->events != NULL)
|
||||||
|
kfree(core_stats->events);
|
||||||
|
|
||||||
kfree(core_stats);
|
kfree(core_stats);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user