From b48e82ca9eee93ccd821cd179951837bf7a22d6a Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 24 Oct 2017 18:35:24 +0200 Subject: rate_ctr: Fix null pointer dereference in error path In Change-Id Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56 we introduced a variable de-reference before we check if it's NULL. Let's reorder the statements to avoid this. Fixes: Coverity CID#178219 Change-Id: I99265a7ee76f85c479543c19ce8c05ce5d43ae69 --- src/rate_ctr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rate_ctr.c b/src/rate_ctr.c index 6de59a02..296cc16e 100644 --- a/src/rate_ctr.c +++ b/src/rate_ctr.c @@ -74,12 +74,13 @@ static void *tall_rate_ctr_ctx; static bool rate_ctrl_group_desc_validate(const struct rate_ctr_group_desc *desc, bool quiet) { unsigned int i; - const struct rate_ctr_desc *ctr_desc = desc->ctr_desc; + const struct rate_ctr_desc *ctr_desc; if (!desc) { LOGP(DLGLOBAL, LOGL_ERROR, "NULL is not a valid counter group descriptor\n"); return false; } + ctr_desc = desc->ctr_desc; DEBUGP(DLGLOBAL, "validating counter group %p(%s) with %u counters\n", desc, desc->group_name_prefix, desc->num_ctr); -- cgit v1.2.3