From patchwork Sun Nov 8 13:28:16 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 58531 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nA8DMtTY014743 for ; Sun, 8 Nov 2009 13:22:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750849AbZKHNWs (ORCPT ); Sun, 8 Nov 2009 08:22:48 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751428AbZKHNWs (ORCPT ); Sun, 8 Nov 2009 08:22:48 -0500 Received: from mail.mellanox.co.il ([194.90.237.43]:46619 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750849AbZKHNWs (ORCPT ); Sun, 8 Nov 2009 08:22:48 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from kliteyn@dev.mellanox.co.il) with SMTP; 8 Nov 2009 15:28:52 +0200 Received: from [10.4.1.29] ([10.4.1.29]) by mtlexch01.mtl.com with Microsoft SMTPSVC(6.0.3790.3959); Sun, 8 Nov 2009 15:22:49 +0200 Message-ID: <4AF6C770.9020107@dev.mellanox.co.il> Date: Sun, 08 Nov 2009 15:28:16 +0200 From: Yevgeny Kliteynik Reply-To: kliteyn@dev.mellanox.co.il User-Agent: Thunderbird 1.5.0.5 (X11/20060719) MIME-Version: 1.0 To: Sasha Khapyorsky CC: Linux RDMA Subject: [PATCH] opensm/complib: bug in cl_list_insert_array_head/tail functions X-OriginalArrivalTime: 08 Nov 2009 13:22:49.0691 (UTC) FILETIME=[917F0AB0:01CA6076] Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/opensm/complib/cl_list.c b/opensm/complib/cl_list.c index a30d3be..555a968 100644 --- a/opensm/complib/cl_list.c +++ b/opensm/complib/cl_list.c @@ -424,6 +424,7 @@ cl_status_t cl_list_insert_array_head(IN cl_list_t * const p_list, { cl_status_t status; void *p_object; + uint32_t items_remain = item_count; CL_ASSERT(p_list); CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool)); @@ -439,11 +440,11 @@ cl_status_t cl_list_insert_array_head(IN cl_list_t * const p_list, p_object = ((uint8_t *) p_array + (item_size * (item_count - 1))); /* Continue to add all items to the list. */ - while (item_count--) { + while (items_remain--) { status = cl_list_insert_head(p_list, p_object); if (status != CL_SUCCESS) { /* Remove all items that have been inserted. */ - while (item_count++ < item_count) + while (items_remain++ < (item_count - 1)) cl_list_remove_head(p_list); return (status); } @@ -462,6 +463,7 @@ cl_status_t cl_list_insert_array_tail(IN cl_list_t * const p_list, { cl_status_t status; void *p_object; + uint32_t items_remain = item_count; CL_ASSERT(p_list); CL_ASSERT(cl_is_qpool_inited(&p_list->list_item_pool)); @@ -473,11 +475,11 @@ cl_status_t cl_list_insert_array_tail(IN cl_list_t * const p_list, p_object = (void *)p_array; /* Continue to add all items to the list. */ - while (item_count--) { + while (items_remain--) { status = cl_list_insert_tail(p_list, p_object); if (status != CL_SUCCESS) { /* Remove all items that have been inserted. */ - while (item_count++ < item_count) + while (items_remain++ < (item_count - 1)) cl_list_remove_tail(p_list); return (status); }