From patchwork Thu Jul 5 14:41:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 939968 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41M0t12mbtz9s2g for ; Fri, 6 Jul 2018 00:41:29 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41M0t11Dt9zF1pM for ; Fri, 6 Jul 2018 00:41:29 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com 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 41M0sx5csVzF1mp for ; Fri, 6 Jul 2018 00:41:25 +1000 (AEST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w65EZ8hY048531 for ; Thu, 5 Jul 2018 10:41:23 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2k1k6fe6k3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Jul 2018 10:41:22 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 5 Jul 2018 15:41:20 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 5 Jul 2018 15:41:19 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w65EfIuG30277636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 5 Jul 2018 14:41:18 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 522E442047; Thu, 5 Jul 2018 17:41:43 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DB7E34203F; Thu, 5 Jul 2018 17:41:41 +0100 (BST) Received: from hegdevasant.in.ibm.com (unknown [9.199.33.12]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 5 Jul 2018 17:41:41 +0100 (BST) From: Vasant Hegde To: pdbg@lists.ozlabs.org Date: Thu, 5 Jul 2018 20:11:15 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 18070514-0016-0000-0000-000001E3B425 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070514-0017-0000-0000-000032382149 Message-Id: <20180705144115.19872-1-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-07-05_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=948 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807050168 Subject: [Pdbg] [PATCH] putmem: Fix Floating point exception issue X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Validate read() before calling __adu_putmem(). Also check end size in progress_tick(). Signed-off-by: Vasant Hegde --- src/mem.c | 3 +++ src/progress.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/mem.c b/src/mem.c index b2ab917..4b2c829 100644 --- a/src/mem.c +++ b/src/mem.c @@ -90,6 +90,9 @@ static int putmem(uint64_t addr, struct mem_flags flags) progress_init(); do { read_size = read(STDIN_FILENO, buf, PUTMEM_BUF_SIZE); + if (read_size <= 0) + break; + if (__adu_putmem(adu_target, addr, buf, read_size, flags.ci)) { rc = 0; printf("Unable to write memory.\n"); diff --git a/src/progress.c b/src/progress.c index fe443b9..e57b8de 100644 --- a/src/progress.c +++ b/src/progress.c @@ -51,6 +51,9 @@ void progress_tick(uint64_t cur, uint64_t end) uint64_t pcent; double sec; + if (end == 0) + return; + pcent = (cur * 100) / end; if (progress_pcent == pcent && cur < progress_n_upd && cur < end)