net: rds: Fix possible null-pointer dereferences in rds_rdma_cm_event_handler_cmn()
authorJia-Ju Bai <baijiaju1990@gmail.com>
Fri, 26 Jul 2019 14:17:05 +0000 (22:17 +0800)
committerDavid S. Miller <davem@davemloft.net>
Sat, 27 Jul 2019 20:58:12 +0000 (13:58 -0700)
commitc7ba50fe2399f0621fae39eb6f5e6abfbb83c38d
tree22b6f6c1191df43be0b299e4b3c0110748e347b6
parenta0d57a552b836206ad7705a1060e6e1ce5a38203
net: rds: Fix possible null-pointer dereferences in rds_rdma_cm_event_handler_cmn()

In rds_rdma_cm_event_handler_cmn(), there are some if statements to
check whether conn is NULL, such as on lines 65, 96 and 112.
But conn is not checked before being used on line 108:
    trans->cm_connect_complete(conn, event);
and on lines 140-143:
    rdsdebug("DISCONNECT event - dropping connection "
            "%pI6c->%pI6c\n", &conn->c_laddr,
            &conn->c_faddr);
    rds_conn_drop(conn);

Thus, possible null-pointer dereferences may occur.

To fix these bugs, conn is checked before being used.

These bugs are found by a static analysis tool STCheck written by us.

Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rds/rdma_transport.c