aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDotan Barak <dotanb@dev.mellanox.co.il>2019-10-01 10:21:02 -0700
committerGreg Kroah-Hartman <gregkh@google.com>2019-10-07 19:49:45 +0200
commit81fd36f07a625d8042ff80348a549d76028f6039 (patch)
tree7e73298be922b1c81bf3054a6864cfaf1ced205e
parent15d76f3d02e8cfdc9b8e6aeebf4dbd5e1adb9466 (diff)
downloadhikey-linaro-81fd36f07a625d8042ff80348a549d76028f6039.tar.gz
net/rds: Fix error handling in rds_ib_add_one()
[ Upstream commit d64bf89a75b65f83f06be9fb8f978e60d53752db ] 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> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I41071cede5c11115f12220a477281619d35342f5
-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 ba2dffeff608..7533954acbf0 100644
--- a/net/rds/ib.c
+++ b/net/rds/ib.c
@@ -146,6 +146,9 @@ static void rds_ib_add_one(struct ib_device *device)
atomic_set(&rds_ibdev->refcount, 1);
INIT_WORK(&rds_ibdev->free_work, rds_ib_dev_free);
+ INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
+ INIT_LIST_HEAD(&rds_ibdev->conn_list);
+
rds_ibdev->max_wrs = dev_attr->max_qp_wr;
rds_ibdev->max_sge = min(dev_attr->max_sge, RDS_IB_MAX_SGE);
@@ -176,9 +179,6 @@ static void rds_ib_add_one(struct ib_device *device)
goto put_dev;
}
- INIT_LIST_HEAD(&rds_ibdev->ipaddr_list);
- INIT_LIST_HEAD(&rds_ibdev->conn_list);
-
down_write(&rds_ib_devices_lock);
list_add_tail_rcu(&rds_ibdev->list, &rds_ib_devices);
up_write(&rds_ib_devices_lock);