diff mbox series

[2/2] osm_gi_rcv_process: OSM_LOG_ENTER should before CL_ASSERT

Message ID 20181113063122.13950-2-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series [1/2] opensm/osm_ucast_mgr.h: Add comment for field 'max_lid' of osm_ucast_mgr_t | expand

Commit Message

Honggang LI Nov. 13, 2018, 6:31 a.m. UTC
From: Honggang Li <honli@redhat.com>

Signed-off-by: Honggang Li <honli@redhat.com>
---
 opensm/osm_guid_info_rcv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Hal Rosenstock Nov. 13, 2018, 12:52 p.m. UTC | #1
On 11/13/2018 1:31 AM, Honggang LI wrote:
> From: Honggang Li <honli@redhat.com>
> 
> Signed-off-by: Honggang Li <honli@redhat.com>
> ---
>  opensm/osm_guid_info_rcv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/opensm/osm_guid_info_rcv.c b/opensm/osm_guid_info_rcv.c
> index f4d0592e..ea3c2c56 100644
> --- a/opensm/osm_guid_info_rcv.c
> +++ b/opensm/osm_guid_info_rcv.c
> @@ -74,10 +74,9 @@ void osm_gi_rcv_process(IN void *context, IN void *data)
>  	ib_net64_t port_guid, node_guid;
>  	uint8_t block_num;
>  
> -	CL_ASSERT(sm);
> -
>  	OSM_LOG_ENTER(sm->p_log);
>  
> +	CL_ASSERT(sm);
>  	CL_ASSERT(p_madw);
>  
>  	p_smp = osm_madw_get_smp_ptr(p_madw);
> 

The CL_ASSERT needs to come before the OSM_LOG_ENTER here. Otherwise,
OSM_LOG_ENTER can chase a null pointer in accessing sm->p_log.

-- Hal
Honggang LI Nov. 13, 2018, 6:41 p.m. UTC | #2
On Tue, Nov 13, 2018 at 07:52:26AM -0500, Hal Rosenstock wrote:
> On 11/13/2018 1:31 AM, Honggang LI wrote:
> > From: Honggang Li <honli@redhat.com>
> > 
> > Signed-off-by: Honggang Li <honli@redhat.com>
> > ---
> >  opensm/osm_guid_info_rcv.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/opensm/osm_guid_info_rcv.c b/opensm/osm_guid_info_rcv.c
> > index f4d0592e..ea3c2c56 100644
> > --- a/opensm/osm_guid_info_rcv.c
> > +++ b/opensm/osm_guid_info_rcv.c
> > @@ -74,10 +74,9 @@ void osm_gi_rcv_process(IN void *context, IN void *data)
> >  	ib_net64_t port_guid, node_guid;
> >  	uint8_t block_num;
> >  
> > -	CL_ASSERT(sm);
> > -
> >  	OSM_LOG_ENTER(sm->p_log);
> >  
> > +	CL_ASSERT(sm);
> >  	CL_ASSERT(p_madw);
> >  
> >  	p_smp = osm_madw_get_smp_ptr(p_madw);
> > 
> 
> The CL_ASSERT needs to come before the OSM_LOG_ENTER here. Otherwise,
> OSM_LOG_ENTER can chase a null pointer in accessing sm->p_log.

Yes, you are right.

thanks
diff mbox series

Patch

diff --git a/opensm/osm_guid_info_rcv.c b/opensm/osm_guid_info_rcv.c
index f4d0592e..ea3c2c56 100644
--- a/opensm/osm_guid_info_rcv.c
+++ b/opensm/osm_guid_info_rcv.c
@@ -74,10 +74,9 @@  void osm_gi_rcv_process(IN void *context, IN void *data)
 	ib_net64_t port_guid, node_guid;
 	uint8_t block_num;
 
-	CL_ASSERT(sm);
-
 	OSM_LOG_ENTER(sm->p_log);
 
+	CL_ASSERT(sm);
 	CL_ASSERT(p_madw);
 
 	p_smp = osm_madw_get_smp_ptr(p_madw);