Skip to content

Commit e766e6a

Browse files
Mikhail Lobanovrleon
authored andcommitted
RDMA/cxgb4: Added NULL check for lookup_atid
The lookup_atid() function can return NULL if the ATID is invalid or does not exist in the identifier table, which could lead to dereferencing a null pointer without a check in the `act_establish()` and `act_open_rpl()` functions. Add a NULL check to prevent null pointer dereferencing. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: cfdda9d ("RDMA/cxgb4: Add driver for Chelsio T4 RNIC") Signed-off-by: Mikhail Lobanov <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 39c047d commit e766e6a

File tree

1 file changed

+5
-0
lines changed
  • drivers/infiniband/hw/cxgb4

1 file changed

+5
-0
lines changed

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,8 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)
12221222
int ret;
12231223

12241224
ep = lookup_atid(t, atid);
1225+
if (!ep)
1226+
return -EINVAL;
12251227

12261228
pr_debug("ep %p tid %u snd_isn %u rcv_isn %u\n", ep, tid,
12271229
be32_to_cpu(req->snd_isn), be32_to_cpu(req->rcv_isn));
@@ -2279,6 +2281,9 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)
22792281
int ret = 0;
22802282

22812283
ep = lookup_atid(t, atid);
2284+
if (!ep)
2285+
return -EINVAL;
2286+
22822287
la = (struct sockaddr_in *)&ep->com.local_addr;
22832288
ra = (struct sockaddr_in *)&ep->com.remote_addr;
22842289
la6 = (struct sockaddr_in6 *)&ep->com.local_addr;

0 commit comments

Comments
 (0)