aboutsummaryrefslogtreecommitdiff
path: root/hw/slw.c
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-11-17 15:27:12 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-11-17 15:27:12 +1100
commit915cd77c123761301c2ae9fee7681cbe120401db (patch)
treee797635ca43b0c89cc8debefa292c798b30b1e2a /hw/slw.c
parent8041e51dc29959c7c2fff6aa93259914a7097397 (diff)
downloadskiboot-915cd77c123761301c2ae9fee7681cbe120401db.zip
skiboot-915cd77c123761301c2ae9fee7681cbe120401db.tar.gz
skiboot-915cd77c123761301c2ae9fee7681cbe120401db.tar.bz2
slw: don't be tricky with pointer math
Mainly because this trips up some static analysis on resource usage and instead of having someone go back and prove it, add an assert and keep around a (no doubt optimized out) variable. Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw/slw.c')
-rw-r--r--hw/slw.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/hw/slw.c b/hw/slw.c
index e1b4368..bb47971 100644
--- a/hw/slw.c
+++ b/hw/slw.c
@@ -518,7 +518,7 @@ void add_cpu_idle_state_properties(void)
u8 i;
/* Buffers to hold idle state properties */
- char *name_buf;
+ char *name_buf, *alloced_name_buf;
u32 *latency_ns_buf;
u32 *residency_ns_buf;
u32 *flags_buf;
@@ -595,7 +595,8 @@ void add_cpu_idle_state_properties(void)
*/
/* Allocate memory to idle state property buffers. */
- name_buf = (char *) malloc(nr_states * sizeof(char) * MAX_NAME_LEN);
+ alloced_name_buf= (char *) malloc(nr_states * sizeof(char) * MAX_NAME_LEN);
+ name_buf = alloced_name_buf;
latency_ns_buf = (u32 *) malloc(nr_states * sizeof(u32));
residency_ns_buf= (u32 *) malloc(nr_states * sizeof(u32));
flags_buf = (u32 *) malloc(nr_states * sizeof(u32));
@@ -661,7 +662,8 @@ void add_cpu_idle_state_properties(void)
dt_add_property(power_mgt, "ibm,cpu-idle-state-pmicr-mask",
pmicr_mask_buf, num_supported_idle_states * sizeof(u64));
- free(name_buf);
+ assert(alloced_name_buf == name_buf);
+ free(alloced_name_buf);
free(latency_ns_buf);
free(residency_ns_buf);
free(flags_buf);