From patchwork Fri Feb 3 00:28:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 93142 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp370328qgi; Thu, 2 Feb 2017 16:28:16 -0800 (PST) X-Received: by 10.107.15.196 with SMTP id 65mr8913064iop.141.1486081696004; Thu, 02 Feb 2017 16:28:16 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id u7si134566itb.27.2017.02.02.16.28.14; Thu, 02 Feb 2017 16:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 645BB62DD6; Fri, 3 Feb 2017 00:28:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 688A860F44; Fri, 3 Feb 2017 00:28:11 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 07C7860F47; Fri, 3 Feb 2017 00:28:08 +0000 (UTC) Received: from mail-ot0-f175.google.com (mail-ot0-f175.google.com [74.125.82.175]) by lists.linaro.org (Postfix) with ESMTPS id 1C2C6609A1 for ; Fri, 3 Feb 2017 00:28:07 +0000 (UTC) Received: by mail-ot0-f175.google.com with SMTP id f9so3428182otd.1 for ; Thu, 02 Feb 2017 16:28:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Em5iMW6ZfClukj3qRQR7cEXH+MB11W0Uht7c7EnkaiQ=; b=ovuXqcN6qcrNbWTSlOlDh4tGinY0NSeMEzAguBX/yIjOcfy2yoo6s8hJzQJiNsx/EY SDlpd0T2Axj3XSr+awC1++d4ZfWzxUFzRH1tlfmTlDNRI+HllmhyNN5bohJb89LNAGpw JEYzENfFRxvfmMvqgIN2MEAnVbmyEm0zOLbOlljqOP3PNREWaR5exsQ1cy1D4uR5LMMt U+QdvC6SQUfHv5uJEQfpUyfoAAoIygQ80kpwlfE3GYi95mUUt0wh5lZJG4KS/7YXNlwi lzNdepwCYCCYz1Qys9kXV+pfs5IHdmiSw8PxHWtHlNIyGCzJ03rFYlix4AvjSVwFkfrV p8sg== X-Gm-Message-State: AIkVDXLxX3vndoa6myKONSj/Cb6/uQn4KTy+yfJAeHByVXKHnFe//2F1rb1dQNQSpC4CnAe+c2c= X-Received: by 10.157.63.162 with SMTP id r31mr5174709otc.39.1486081686628; Thu, 02 Feb 2017 16:28:06 -0800 (PST) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id u19sm13094328ota.12.2017.02.02.16.28.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2017 16:28:05 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 2 Feb 2017 18:28:00 -0600 Message-Id: <20170203002802.28881-1-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce Subject: [lng-odp] [PATCH 1/3] helper: cuckootable: avoid storage leaks on error paths X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Ensure that malloced storage areas are freed on error paths. This resolves Bug https://bugs.linaro.org/show_bug.cgi?id=2830 Signed-off-by: Bill Fischofer --- helper/test/cuckootable.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.11.0.295.gd7dffce diff --git a/helper/test/cuckootable.c b/helper/test/cuckootable.c index 002e52e0..be655911 100644 --- a/helper/test/cuckootable.c +++ b/helper/test/cuckootable.c @@ -453,10 +453,15 @@ static int test_performance(int number) unsigned key_num = key_len * elem_num; key_space = (uint8_t *)malloc(key_num); - key_ptr = (const void **)malloc(sizeof(void *) * elem_num); if (key_space == NULL) return -ENOENT; + key_ptr = (const void **)malloc(sizeof(void *) * elem_num); + if (key_ptr == NULL) { + free(key_space); + return -ENOENT; + } + for (j = 0; j < key_num; j++) { key_space[j] = rand() % 255; if (j % key_len == 0) @@ -473,6 +478,8 @@ static int test_performance(int number) "performance_test", PERFORMANCE_CAPACITY, key_len, 0); if (table == NULL) { printf("cuckoo table creation failed\n"); + free(key_ptr); + free(key_space); return -ENOENT; }