From patchwork Wed Jun 14 06:08:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 775614 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wnbw86P28z9s1h for ; Wed, 14 Jun 2017 16:15:20 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wnbw839v2zDqLQ for ; Wed, 14 Jun 2017 16:15:20 +1000 (AEST) 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 3wnbn40GHbzDq5j for ; Wed, 14 Jun 2017 16:09:11 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5E656Vg141988 for ; Wed, 14 Jun 2017 02:09:09 -0400 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 2b2w0k5hdx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 14 Jun 2017 02:09:09 -0400 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Jun 2017 16:09:07 +1000 Received: from d23relay08.au.ibm.com (202.81.31.227) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Jun 2017 16:09:05 +1000 Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v5E694Sm64356412 for ; Wed, 14 Jun 2017 16:09:04 +1000 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v5E694N5021541 for ; Wed, 14 Jun 2017 16:09:04 +1000 Received: from hegdevasant.in.ibm.com (hegdevasant.in.ibm.com [9.124.35.202]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v5E693Ur021485; Wed, 14 Jun 2017 16:09:03 +1000 From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Wed, 14 Jun 2017 11:38:56 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-MML: disable x-cbid: 17061406-0052-0000-0000-00000255C2A0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17061406-0053-0000-0000-00000833EB02 Message-Id: <20170614060856.27717-1-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-06-14_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-1703280000 definitions=main-1706140109 Subject: [Skiboot] [trivial PATCH] FSP/CONSOLE: 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" Fix coverity warning message. Null pointer dereferences (NULL_RETURNS) /hw/fsp/fsp-console.c: 295 in fsp_open_vserial() 289 290 fs->open = true; 291 292 fs->poke_msg = fsp_mkmsg(FSP_CMD_VSERIAL_OUT, 2, 293 msg->data.words[0], 294 msg->data.words[1] & 0xffff); >>> CID 145796: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a null pointer "fs->poke_msg". 295 fs->poke_msg->user_data = fs; 296 297 fs->in_buf->partition_id = fs->out_buf->partition_id = part_id; 298 fs->in_buf->session_id = fs->out_buf->session_id = sess_id; 299 fs->in_buf->hmc_id = fs->out_buf->hmc_id = hmc_indx; 300 fs->in_buf->data_offset = fs->out_buf->data_offset = Signed-off-by: Vasant Hegde --- hw/fsp/fsp-console.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/fsp/fsp-console.c b/hw/fsp/fsp-console.c index 2ba879b..a855133 100644 --- a/hw/fsp/fsp-console.c +++ b/hw/fsp/fsp-console.c @@ -291,11 +291,16 @@ static void fsp_open_vserial(struct fsp_msg *msg) goto already_open; } - fs->open = true; - fs->poke_msg = fsp_mkmsg(FSP_CMD_VSERIAL_OUT, 2, msg->data.words[0], msg->data.words[1] & 0xffff); + if (fs->poke_msg == NULL) { + prerror("FSPCON: Failed to allocate poke_msg\n"); + unlock(&fsp_con_lock); + return; + } + + fs->open = true; fs->poke_msg->user_data = fs; fs->in_buf->partition_id = fs->out_buf->partition_id = part_id;