From patchwork Thu Aug 2 04:35:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 952579 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 41gy5w39y4z9s2g for ; Thu, 2 Aug 2018 14:35:32 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FbksvW/o"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 41gy5w0wh4zF1dK for ; Thu, 2 Aug 2018 14:35:32 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FbksvW/o"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41gy5X09JfzF1Qn for ; Thu, 2 Aug 2018 14:35:12 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="FbksvW/o"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 41gy5W4mCLz9rxx; Thu, 2 Aug 2018 14:35:11 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1533184511; bh=EPRYic/UoqMU8I6cf9opj1yegNCsaBkFOM7wo/Dgt1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FbksvW/obj7wLCAlsKbSq1eB6qszh4LxnQ6OjYD7O6wA5wwc7Z9ML7Zv2e2RcUCWE W0GXcr4hmFaXsRQXptCjSRDNCz9HNv5/HwWPEzZ3jTj1j+RnLDV+DqGy1dYOaC9RJh E8Un9YHwFw50cY80UsOOtdAaO3RApR5ixQWFmKDNGvae8d2r7bTm3Uyy1ZkpzXjHqI Bw/dZieIKijxB2brtq3LtLRMkI6dIIUxykXoFm2mBPGpUIk1Xm9phN7eff8I4w4kST IbLmEUTB9qnVR2H+p/8tIxF/tZTp4Ig++DmK7EMA/tb887ghKGV7N1BuO52Mg0jurS 12yvdeEU/13EA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 2 Aug 2018 14:35:07 +1000 Message-Id: <20180802043507.28734-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180802043507.28734-1-amitay@ozlabs.org> References: <20180802043507.28734-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 4/4] mem: Avoid floating point exception if size == 0 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: , Cc: Amitay Isaacs MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs --- src/mem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mem.c b/src/mem.c index 4b2c829..ce099c2 100644 --- a/src/mem.c +++ b/src/mem.c @@ -46,6 +46,11 @@ static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags) uint8_t *buf; int rc = 0; + if (size == 0) { + PR_ERROR("Size must be > 0\n"); + return 1; + } + buf = malloc(size); assert(buf); pdbg_for_each_class_target("adu", target) {