From patchwork Tue Sep 7 15:18:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 161291 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o87FJ4TC003069 for ; Tue, 7 Sep 2010 15:19:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757273Ab0IGPSz (ORCPT ); Tue, 7 Sep 2010 11:18:55 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:56372 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757059Ab0IGPSy (ORCPT ); Tue, 7 Sep 2010 11:18:54 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from kliteyn@mellanox.co.il) with SMTP; 7 Sep 2010 18:18:12 +0300 Received: from [10.4.1.29] (10.4.1.29) by mtlmail01.mtl.com (10.0.8.12) with Microsoft SMTP Server id 8.2.254.0; Tue, 7 Sep 2010 18:18:51 +0300 Message-ID: <4C8657D1.40900@mellanox.co.il> Date: Tue, 7 Sep 2010 18:18:41 +0300 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 , Linux RDMA Subject: [PATCH] opensm/st.c: fix potential core dumps Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 07 Sep 2010 15:19:05 +0000 (UTC) diff --git a/opensm/opensm/st.c b/opensm/opensm/st.c index ea76038..469ba9d 100644 --- a/opensm/opensm/st.c +++ b/opensm/opensm/st.c @@ -194,6 +194,8 @@ size_t size; #endif size = new_size(size); /* round up to prime number */ + if (size < 0) + return NULL; tbl = alloc(st_table); tbl->type = type; @@ -351,6 +353,9 @@ register st_table *table; unsigned int hash_val; new_num_bins = new_size(old_num_bins + 1); + if (new_num_bins < 0) + return; + new_bins = (st_table_entry **) Calloc(new_num_bins, sizeof(st_table_entry *));