summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarun Prakash <varun@chelsio.com>2019-05-22 20:10:55 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-06-22 08:17:24 +0200
commit1a0c974d23778001eb80debd49d8d0baedcf530f (patch)
tree1dbcae1cc8ebff335209b8d0b23fecbf338b6795
parent9b25b0c790c566275ac6fbeefd6d90c9a56f64ab (diff)
downloadlinux-stable-1a0c974d23778001eb80debd49d8d0baedcf530f.tar.gz
linux-stable-1a0c974d23778001eb80debd49d8d0baedcf530f.tar.bz2
linux-stable-1a0c974d23778001eb80debd49d8d0baedcf530f.zip
scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route()
[ Upstream commit cc555759117e8349088e0c5d19f2f2a500bafdbd ] ip_dev_find() can return NULL so add a check for NULL pointer. Signed-off-by: Varun Prakash <varun@chelsio.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/scsi/cxgbi/libcxgbi.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 2ffe029ff2b6..e974106f2bb5 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -637,6 +637,10 @@ static struct cxgbi_sock *cxgbi_check_route(struct sockaddr *dst_addr)
if (ndev->flags & IFF_LOOPBACK) {
ndev = ip_dev_find(&init_net, daddr->sin_addr.s_addr);
+ if (!ndev) {
+ err = -ENETUNREACH;
+ goto rel_neigh;
+ }
mtu = ndev->mtu;
pr_info("rt dev %s, loopback -> %s, mtu %u.\n",
n->dev->name, ndev->name, mtu);