net/smc: fix direct access to ib_gid_addr->ndev in smc_ib_determine_gid()
authorKarsten Graul <kgraul@linux.ibm.com>
Wed, 18 Nov 2020 21:40:38 +0000 (22:40 +0100)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Nov 2020 18:59:19 +0000 (10:59 -0800)
Sparse complaints 3 times about:
net/smc/smc_ib.c:203:52: warning: incorrect type in argument 1 (different address spaces)
net/smc/smc_ib.c:203:52:    expected struct net_device const *dev
net/smc/smc_ib.c:203:52:    got struct net_device [noderef] __rcu *const ndev

Fix that by using the existing and validated ndev variable instead of
accessing attr->ndev directly.

Fixes: 5102eca9039b ("net/smc: Use rdma_read_gid_l2_fields to L2 fields")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/smc/smc_ib.c

index 1c314dbdc7faa450ead0cf45279f87a97f26f603..fc766b537ac7a9c2b36272c7f9b03e567b7bc6d0 100644 (file)
@@ -198,9 +198,9 @@ int smc_ib_determine_gid(struct smc_ib_device *smcibdev, u8 ibport,
                rcu_read_lock();
                ndev = rdma_read_gid_attr_ndev_rcu(attr);
                if (!IS_ERR(ndev) &&
-                   ((!vlan_id && !is_vlan_dev(attr->ndev)) ||
-                    (vlan_id && is_vlan_dev(attr->ndev) &&
-                     vlan_dev_vlan_id(attr->ndev) == vlan_id)) &&
+                   ((!vlan_id && !is_vlan_dev(ndev)) ||
+                    (vlan_id && is_vlan_dev(ndev) &&
+                     vlan_dev_vlan_id(ndev) == vlan_id)) &&
                    attr->gid_type == IB_GID_TYPE_ROCE) {
                        rcu_read_unlock();
                        if (gid)