Skip to content

Commit 36a4043

Browse files
Dotan Barakgregkh
authored andcommitted
net/rds: Fix error handling in rds_ib_add_one()
[ Upstream commit d64bf89 ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 012363f commit 36a4043

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

net/rds/ib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ static void rds_ib_add_one(struct ib_device *device)
143143
refcount_set(&rds_ibdev->refcount, 1);
144144
INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free);
145145

146+
INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
147+
INIT_LIST_HEAD(&rds_ibdev->conn_list);
148+
146149
rds_ibdev->max_wrs = device->attrs.max_qp_wr;
147150
rds_ibdev->max_sge = min(device->attrs.max_send_sge, RDS_IB_MAX_SGE);
148151

@@ -203,9 +206,6 @@ static void rds_ib_add_one(struct ib_device *device)
203206
device->name,
204207
rds_ibdev->use_fastreg ? "FRMR" : "FMR");
205208

206-
INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
207-
INIT_LIST_HEAD(&rds_ibdev->conn_list);
208-
209209
down_write(&rds_ib_devices_lock);
210210
list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices);
211211
up_write(&rds_ib_devices_lock);

0 commit comments

Comments
 (0)