From patchwork Tue Sep 7 15:17:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yevgeny Kliteynik X-Patchwork-Id: 161271 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 o87FHwgL002973 for ; Tue, 7 Sep 2010 15:17:59 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756404Ab0IGPR6 (ORCPT ); Tue, 7 Sep 2010 11:17:58 -0400 Received: from mail.mellanox.co.il ([194.90.237.43]:56276 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752853Ab0IGPR5 (ORCPT ); Tue, 7 Sep 2010 11:17:57 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from kliteyn@mellanox.co.il) with SMTP; 7 Sep 2010 18:17:16 +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:17:55 +0300 Message-ID: <4C8657A2.8020106@mellanox.co.il> Date: Tue, 7 Sep 2010 18:17:54 +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/osm_qos_parser_y.y: fixing bunch of memory leaks on invalid values 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:17:59 +0000 (UTC) diff --git a/opensm/opensm/osm_qos_parser_y.y b/opensm/opensm/osm_qos_parser_y.y index 7118b79..d9830dc 100644 --- a/opensm/opensm/osm_qos_parser_y.y +++ b/opensm/opensm/osm_qos_parser_y.y @@ -763,6 +763,7 @@ qos_ulp: TK_ULP_DEFAULT single_number { if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF) { yyerror("SDP port number out of range"); + free(range_arr); return 1; } range_arr[i][0] += OSM_QOS_POLICY_ULP_SDP_SERVICE_ID; @@ -809,6 +810,7 @@ qos_ulp: TK_ULP_DEFAULT single_number { if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF) { yyerror("SDP port number out of range"); + free(range_arr); return 1; } range_arr[i][0] += OSM_QOS_POLICY_ULP_RDS_SERVICE_ID; @@ -855,6 +857,7 @@ qos_ulp: TK_ULP_DEFAULT single_number { if (range_arr[i][0] > 0xFFFF || range_arr[i][1] > 0xFFFF) { yyerror("SDP port number out of range"); + free(range_arr); return 1; } range_arr[i][0] += OSM_QOS_POLICY_ULP_ISER_SERVICE_ID; @@ -944,8 +947,10 @@ qos_ulp: TK_ULP_DEFAULT single_number { * If some problem would be found, parsing will * be aborted with a proper error messages. */ - if (__validate_pkeys(range_arr, range_len, TRUE)) + if (__validate_pkeys(range_arr, range_len, TRUE)) { + free(range_arr); return 1; + } p_current_qos_match_rule->pkey_range_arr = range_arr; p_current_qos_match_rule->pkey_range_len = range_len;