summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2017-02-23 13:01:42 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-03-02 18:22:43 +1100
commit0d31de63ff037a4a0d77ce96005977b62ce12532 (patch)
tree7b74f7639a32fd4bcb8344b29ddf8f778ab34ab1
parent42b7ef13b3475199791ce2cdc6e6f9858003f670 (diff)
downloadtalos-skiboot-0d31de63ff037a4a0d77ce96005977b62ce12532.tar.gz
talos-skiboot-0d31de63ff037a4a0d77ce96005977b62ce12532.zip
hw/slw: fix possible NULL dereference
Found by static analysis Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--hw/slw.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/hw/slw.c b/hw/slw.c
index 97d47586..bea1028d 100644
--- a/hw/slw.c
+++ b/hw/slw.c
@@ -1219,11 +1219,17 @@ int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val)
{
struct cpu_thread *c = find_cpu_by_pir(cpu_pir);
- struct proc_chip *chip = get_chip(c->chip_id);
- void *image = (void *) chip->slw_base;
+ struct proc_chip *chip;
+ void *image;
int rc;
int i;
int spr_is_supported = 0;
+
+ assert(c);
+ chip = get_chip(c->chip_id);
+ assert(chip);
+ image = (void *) chip->slw_base;
+
/* Check of the SPR is supported by libpore */
for ( i=0; i < SLW_SPR_REGS_SIZE ; i++) {
if (sprn == SLW_SPR_REGS[i].value) {
OpenPOWER on IntegriCloud