Skip to content

Commit

Permalink
crypto: chelsio - Fix potential NULL pointer dereferences
Browse files Browse the repository at this point in the history
Add null checks on lookup_tid() return value in order to prevent
null pointer dereferences.

Addresses-Coverity-ID: 1467422 ("Dereference null return value")
Addresses-Coverity-ID: 1467443 ("Dereference null return value")
Addresses-Coverity-ID: 1467445 ("Dereference null return value")
Addresses-Coverity-ID: 1467449 ("Dereference null return value")
Fixes: cc35c88 ("crypto : chtls - CPL handler definition")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
  • Loading branch information
Gustavo A. R. Silva authored and Herbert Xu committed Apr 20, 2018
1 parent 31545df commit 3d8ccf9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions drivers/crypto/chelsio/chtls/chtls_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,10 @@ static int chtls_rx_data(struct chtls_dev *cdev, struct sk_buff *skb)
struct sock *sk;

sk = lookup_tid(cdev->tids, hwtid);
if (unlikely(!sk)) {
pr_err("can't find conn. for hwtid %u.\n", hwtid);
return -EINVAL;
}
skb_dst_set(skb, NULL);
process_cpl_msg(chtls_recv_data, sk, skb);
return 0;
Expand Down Expand Up @@ -1585,6 +1589,10 @@ static int chtls_rx_pdu(struct chtls_dev *cdev, struct sk_buff *skb)
struct sock *sk;

sk = lookup_tid(cdev->tids, hwtid);
if (unlikely(!sk)) {
pr_err("can't find conn. for hwtid %u.\n", hwtid);
return -EINVAL;
}
skb_dst_set(skb, NULL);
process_cpl_msg(chtls_recv_pdu, sk, skb);
return 0;
Expand Down Expand Up @@ -1646,6 +1654,10 @@ static int chtls_rx_cmp(struct chtls_dev *cdev, struct sk_buff *skb)
struct sock *sk;

sk = lookup_tid(cdev->tids, hwtid);
if (unlikely(!sk)) {
pr_err("can't find conn. for hwtid %u.\n", hwtid);
return -EINVAL;
}
skb_dst_set(skb, NULL);
process_cpl_msg(chtls_rx_hdr, sk, skb);

Expand Down Expand Up @@ -2105,6 +2117,10 @@ static int chtls_wr_ack(struct chtls_dev *cdev, struct sk_buff *skb)
struct sock *sk;

sk = lookup_tid(cdev->tids, hwtid);
if (unlikely(!sk)) {
pr_err("can't find conn. for hwtid %u.\n", hwtid);
return -EINVAL;
}
process_cpl_msg(chtls_rx_ack, sk, skb);

return 0;
Expand Down

0 comments on commit 3d8ccf9

Please sign in to comment.