summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDotan Barak <dotanb@dev.mellanox.co.il>2019-10-01 13:21:02 -0400
committerDavid S. Miller <davem@davemloft.net>2019-10-02 12:16:57 -0400
commitd64bf89a75b65f83f06be9fb8f978e60d53752db (patch)
tree783d0cc21944c1e8346db9e62051418e08bc9e49
parente8521e53cca584ddf8ec4584d3c550a6c65f88c4 (diff)
net/rds: Fix error handling in rds_ib_add_one()
rds_ibdev:ipaddr_list and rds_ibdev:conn_list are initialized after allocation some resources such as protection domain. If allocation of such resources fail, then these uninitialized variables are accessed in rds_ib_dev_free() in failure path. This can potentially crash the system. The code has been updated to initialize these variables very early in the function. Signed-off-by: Dotan Barak <dotanb@dev.mellanox.co.il> Signed-off-by: Sudhakar Dindukurti <sudhakar.dindukurti@oracle.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/rds/ib.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/rds/ib.c b/net/rds/ib.c
index 45acab2de0cf..9de2ae22d583 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -143,6 +143,9 @@ static void rds_ib_add_one(struct ib_device *device)
143 refcount_set(&rds_ibdev->refcount, 1); 143 refcount_set(&rds_ibdev->refcount, 1);
144 INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free); 144 INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free);
145 145
146 INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
147 INIT_LIST_HEAD(&rds_ibdev->conn_list);
148
146 rds_ibdev->max_wrs = device->attrs.max_qp_wr; 149 rds_ibdev->max_wrs = device->attrs.max_qp_wr;
147 rds_ibdev->max_sge = min(device->attrs.max_send_sge, RDS_IB_MAX_SGE); 150 rds_ibdev->max_sge = min(device->attrs.max_send_sge, RDS_IB_MAX_SGE);
148 151
@@ -203,9 +206,6 @@ static void rds_ib_add_one(struct ib_device *device)
203 device->name, 206 device->name,
204 rds_ibdev->use_fastreg ? "FRMR" : "FMR"); 207 rds_ibdev->use_fastreg ? "FRMR" : "FMR");
205 208
206 INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
207 INIT_LIST_HEAD(&rds_ibdev->conn_list);
208
209 down_write(&rds_ib_devices_lock); 209 down_write(&rds_ib_devices_lock);
210 list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices); 210 list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices);
211 up_write(&rds_ib_devices_lock); 211 up_write(&rds_ib_devices_lock);