Commit 3b82ce17 authored by Colin Ian King's avatar Colin Ian King Committed by Greg Kroah-Hartman

RDMA/cxgb4: Fix null pointer dereference on alloc_skb failure

[ Upstream commit a6d2a5a9 ]

Currently if alloc_skb fails to allocate the skb a null skb is passed to
t4_set_arp_err_handler and this ends up dereferencing the null skb.  Avoid
the NULL pointer dereference by checking for a NULL skb and returning
early.

Addresses-Coverity: ("Dereference null return")
Fixes: b38a0ad8 ("RDMA/cxgb4: Set arp error handler for PASS_ACCEPT_RPL messages")
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Acked-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 9f641ee2
...@@ -455,6 +455,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp) ...@@ -455,6 +455,8 @@ static struct sk_buff *get_skb(struct sk_buff *skb, int len, gfp_t gfp)
skb_reset_transport_header(skb); skb_reset_transport_header(skb);
} else { } else {
skb = alloc_skb(len, gfp); skb = alloc_skb(len, gfp);
if (!skb)
return NULL;
} }
t4_set_arp_err_handler(skb, NULL, NULL); t4_set_arp_err_handler(skb, NULL, NULL);
return skb; return skb;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment