diff mbox series

[ibsim,13/23] sim_mad.c: fix potential dereference of a null pointer in do_sl2vl

Message ID 20190102131318.5765-13-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series [ibsim,01/23] move sim_cmd_file into ibsim/sim_cmd.c | expand

Commit Message

Honggang LI Jan. 2, 2019, 1:13 p.m. UTC
Issue was detected by Coverity.

ibsim-0.7/ibsim/sim_mad.c:407:31: warning: Access to field 'node' results in a dereference of a null pointer (loaded from variable 'port')
//                if (!port && !node_get_port(port->node, n))

Signed-off-by: Honggang Li <honli@redhat.com>
---
 ibsim/sim_mad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hal Rosenstock Jan. 4, 2019, 7:25 p.m. UTC | #1
On 1/2/2019 8:13 AM, Honggang Li wrote:
> Issue was detected by Coverity.
> 
> ibsim-0.7/ibsim/sim_mad.c:407:31: warning: Access to field 'node' results in a dereference of a null pointer (loaded from variable 'port')
> //                if (!port && !node_get_port(port->node, n))
> 
> Signed-off-by: Honggang Li <honli@redhat.com>

Thanks. Applied.

-- Hal
diff mbox series

Patch

diff --git a/ibsim/sim_mad.c b/ibsim/sim_mad.c
index 1660b84dbe4b..a89e2d62afd8 100644
--- a/ibsim/sim_mad.c
+++ b/ibsim/sim_mad.c
@@ -404,7 +404,7 @@  static int do_sl2vl(Port * port, unsigned op, uint32_t mod, uint8_t * data)
 		n = (mod >> 8) & 0xff;
 		port = node_get_port(port->node, n);
 		n = mod & 0xff;
-		if (!port && !node_get_port(port->node, n))
+		if (!port || !node_get_port(port->node, n))
 			return ERR_BAD_PARAM;
 	} else
 		n = 0;