scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route() [Linux 4.14.129]

scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route() [Linux 4.14.129]

This Linux kernel change "scsi: libcxgbi: add a check for NULL pointer in cxgbi_check_route()" is included in the Linux 4.14.129 release. This change is authored by Varun Prakash <varun [at] chelsio.com> on Wed May 22 20:10:55 2019 +0530. The commit for this change in Linux stable tree is 60ac7a4 (patch) which is from upstream commit cc55575. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream cc55575.

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 <[email protected]>
Signed-off-by: Martin K. Petersen <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/scsi/cxgbi/libcxgbi.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c
index 512c8f1..902f5e0 100644
--- a/drivers/scsi/cxgbi/libcxgbi.c
+++ b/drivers/scsi/cxgbi/libcxgbi.c
@@ -640,6 +640,10 @@ static struct rtable *find_route_ipv4(struct flowi4 *fl4,

    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);

Leave a Reply

Your email address will not be published. Required fields are marked *