From: Colin Ian King <colin.king@xxxxxxxxxxxxx> Currently function construct calls destruct if the allocation of dc->current_state fails, however, the destruct function will attempt dereference dc->current_state when calling dc_release_state. Avoid this null pointer dereference by checking if the pointer is not null before calling dc_release_state. Addresses-Coverity: ("Dereference after null check") Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx> --- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c index 18c775a950cc..0e1f132ae310 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c @@ -608,8 +608,10 @@ const struct dc_link_settings *dc_link_get_link_cap( static void destruct(struct dc *dc) { - dc_release_state(dc->current_state); - dc->current_state = NULL; + if (dc->current_state) { + dc_release_state(dc->current_state); + dc->current_state = NULL; + } destroy_links(dc); -- 2.20.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/dri-devel