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
diff --git a/src/rate_ctr.c b/src/rate_ctr.c
index 6de59a0..296cc16 100644
--- a/src/rate_ctr.c
+++ b/src/rate_ctr.c
@@ -74,12 +74,13 @@
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);