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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 ibsim/sim_mad.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.15.0-rc1




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux