public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Khapyorsky <sashak@voltaire.com>
To: OpenIB <general@lists.openfabrics.org>,
	linux-rdma <linux-rdma@vger.kernel.org>
Subject: [ofa-general] [PATCH] opensm/osm_ucast_lash: fix use after free bug
Date: Fri, 25 Sep 2009 17:50:45 +0300	[thread overview]
Message-ID: <20090925145045.GF26931@me> (raw)
In-Reply-To: <20090925135256.GE26931@me>


When LASH runs its switch structures cleanup OpenSM can rediscover a
subnet and 'p_sw' pointer may refer already freed memory, so don't touch
it, just free our own stuff. (Note also that for valids OpenSM switches
objects' 'priv' pointers are cleared on lash_cleanup()).

Signed-off-by: Sasha Khapyorsky <sashak@voltaire.com>
---
 opensm/opensm/osm_ucast_lash.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/opensm/opensm/osm_ucast_lash.c b/opensm/opensm/osm_ucast_lash.c
index dbc6bcc..3c424cb 100644
--- a/opensm/opensm/osm_ucast_lash.c
+++ b/opensm/opensm/osm_ucast_lash.c
@@ -628,8 +628,7 @@ static switch_t *switch_create(lash_t * p_lash, unsigned id, osm_switch_t * p_sw
 	}
 
 	sw->p_sw = p_sw;
-	if (p_sw)
-		p_sw->priv = sw;
+	p_sw->priv = sw;
 
 	if (osm_mesh_node_create(p_lash, sw)) {
 		free(sw->dij_channels);
@@ -644,8 +643,6 @@ static void switch_delete(lash_t *p_lash, switch_t * sw)
 {
 	if (sw->dij_channels)
 		free(sw->dij_channels);
-	if (sw->p_sw)
-		sw->p_sw->priv = NULL;
 	free(sw);
 }
 
-- 
1.6.5.rc1

       reply	other threads:[~2009-09-25 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1251486496-24812-1-git-send-email-jaschut@sandia.gov>
     [not found] ` <1251486496-24812-2-git-send-email-jaschut@sandia.gov>
     [not found]   ` <20090922185014.GF24398@me>
     [not found]     ` <1253651343.4776.1125.camel@sale659.sandia.gov>
     [not found]       ` <20090925135256.GE26931@me>
2009-09-25 14:50         ` Sasha Khapyorsky [this message]
2009-09-25 22:15           ` [PATCH] opensm/osm_ucast_lash: fix use after free bug Jim Schutt
2009-09-25 23:11           ` Hal Rosenstock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090925145045.GF26931@me \
    --to=sashak@voltaire.com \
    --cc=general@lists.openfabrics.org \
    --cc=linux-rdma@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox