From patchwork Mon Aug 6 06:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Honggang LI X-Patchwork-Id: 10556519 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5F4915A6 for ; Mon, 6 Aug 2018 06:23:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD33C29298 for ; Mon, 6 Aug 2018 06:23:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0D1D2929A; Mon, 6 Aug 2018 06:23:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 549C029298 for ; Mon, 6 Aug 2018 06:23:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725735AbeHFIbU (ORCPT ); Mon, 6 Aug 2018 04:31:20 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:59602 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725739AbeHFIbU (ORCPT ); Mon, 6 Aug 2018 04:31:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F3330738EF; Mon, 6 Aug 2018 06:23:47 +0000 (UTC) Received: from dhcp-129-124.nay.redhat.com (unknown [10.66.129.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 630342166BA0; Mon, 6 Aug 2018 06:23:45 +0000 (UTC) From: Honggang LI To: hal@dev.mellanox.co.il Cc: linux-rdma@vger.kernel.org, Honggang Li Subject: [PATCH] osm_db_files.c: fix bad free Date: Mon, 6 Aug 2018 14:23:42 +0800 Message-Id: <20180806062342.3623-1-honli@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 06 Aug 2018 06:23:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 06 Aug 2018 06:23:48 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'honli@redhat.com' RCPT:'' Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Honggang Li This issue was found by Coverity. Error: BAD_FREE (CWE-763): [#def64] opensm-3.3.20/opensm/osm_db_pack.c:260: array_free: "osm_db_delete" frees array "guid_str". opensm-3.3.20/opensm/osm_db_files.c:665:4: freed_arg: "free" frees parameter "p_key". Signed-off-by: Honggang Li --- opensm/osm_db_files.c | 1 - 1 file changed, 1 deletion(-) diff --git a/opensm/osm_db_files.c b/opensm/osm_db_files.c index 7be976bb..2e0d6a96 100644 --- a/opensm/osm_db_files.c +++ b/opensm/osm_db_files.c @@ -662,7 +662,6 @@ int osm_db_delete(IN osm_db_domain_t * p_domain, IN char *p_key) p_key, p_domain_imp->file_name, p_prev_val); res = 1; } else { - free(p_key); free(p_prev_val); p_domain_imp->dirty = TRUE; res = 0;