From patchwork Thu Feb 23 02:01:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stewart Smith X-Patchwork-Id: 731366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vTHYD2jTkz9s74 for ; Thu, 23 Feb 2017 13:02:08 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3vTHYD0d95zDqH8 for ; Thu, 23 Feb 2017 13:02:08 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3vTHY43sFjzDq5x for ; Thu, 23 Feb 2017 13:02:00 +1100 (AEDT) Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1N1wgDa045381 for ; Wed, 22 Feb 2017 21:01:57 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 28shkstf2r-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 22 Feb 2017 21:01:57 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 22 Feb 2017 19:01:57 -0700 Received: from d03dlp01.boulder.ibm.com (9.17.202.177) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 22 Feb 2017 19:01:55 -0700 Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d03dlp01.boulder.ibm.com (Postfix) with ESMTP id F09A31FF0026 for ; Wed, 22 Feb 2017 19:01:31 -0700 (MST) Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1N21rYQ56754356 for ; Thu, 23 Feb 2017 02:01:54 GMT Received: from localhost (unknown [127.0.0.1]) by IMSVA (Postfix) with SMTP id 7D2B2112054 for ; Wed, 22 Feb 2017 21:01:53 -0500 (EST) X-IMSS-HAND-OFF-DIRECTIVE: 127.0.0.1:10026 Received: from birb.localdomain (unknown [9.185.16.50]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 56B99112069; Wed, 22 Feb 2017 21:01:47 -0500 (EST) Received: by birb.localdomain (Postfix, from userid 1000) id 820A3229DB4D; Thu, 23 Feb 2017 13:01:43 +1100 (AEDT) From: Stewart Smith To: skiboot@lists.ozlabs.org Date: Thu, 23 Feb 2017 13:01:42 +1100 X-Mailer: git-send-email 2.9.3 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022302-0016-0000-0000-000006401116 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006666; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000204; SDB=6.00825755; UDB=6.00404354; IPR=6.00603210; BA=6.00005166; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014401; XFM=3.00000011; UTC=2017-02-23 02:01:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022302-0017-0000-0000-000037A37125 Message-Id: <20170223020142.4496-1-stewart@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-23_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702230015 Subject: [Skiboot] [PATCH] hw/slw: fix possible NULL dereference X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Found by static analysis Signed-off-by: Stewart Smith --- hw/slw.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/slw.c b/hw/slw.c index 97d475862712..bea1028dd091 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) {