Merge "msm: msm_bus: Add checks for deprecated nodes in bus topology" into msm-3.0
diff --git a/arch/arm/mach-msm/include/mach/msm_bus_board.h b/arch/arm/mach-msm/include/mach/msm_bus_board.h
index b0d69c7..ddbf959 100644
--- a/arch/arm/mach-msm/include/mach/msm_bus_board.h
+++ b/arch/arm/mach-msm/include/mach/msm_bus_board.h
@@ -92,6 +92,7 @@
#define NODE_ID(id) ((id) & (FABRIC_ID_KEY - 1))
#define IS_SLAVE(id) ((NODE_ID(id)) >= SLAVE_ID_KEY ? 1 : 0)
+#define CHECK_ID(iid, id) (((iid & id) != id) ? -ENXIO : iid)
/*
* The following macros are used to format the data for port halt
diff --git a/arch/arm/mach-msm/msm_bus/msm_bus_arb.c b/arch/arm/mach-msm/msm_bus/msm_bus_arb.c
index 7b9a16e..8175738 100644
--- a/arch/arm/mach-msm/msm_bus/msm_bus_arb.c
+++ b/arch/arm/mach-msm/msm_bus/msm_bus_arb.c
@@ -144,6 +144,11 @@
/* Are we there yet? */
if (src == dest) {
info = fabdev->algo->find_node(fabdev, src);
+ if (ZERO_OR_NULL_PTR(info)) {
+ MSM_BUS_ERR("Node %d not found\n", dest);
+ return -ENXIO;
+ }
+
for (i = 0; i <= info->num_pnodes; i++) {
if (info->pnode[i].next == -2) {
MSM_BUS_DBG("src = dst Reusing pnode for"
@@ -161,7 +166,7 @@
next_pnode_id = CREATE_PNODE_ID(src, (info->num_pnodes + 1));
pnode_num = add_path_node(info, next_pnode_id);
if (pnode_num < 0) {
- MSM_BUS_DBG("error adding path node\n");
+ MSM_BUS_ERR("Error adding path node\n");
return -ENXIO;
}
MSM_BUS_DBG("returning: %d, %d\n", GET_NODE(next_pnode_id),
@@ -173,6 +178,11 @@
* from the radix tree
*/
info = fabdev->algo->find_node(fabdev, dest);
+ if (ZERO_OR_NULL_PTR(info)) {
+ MSM_BUS_ERR("Node %d not found\n", dest);
+ return -ENXIO;
+ }
+
ret_pnode = getpath(info->node_info->priv_id, dest);
next_pnode_id = ret_pnode;
} else {
@@ -190,7 +200,7 @@
dest);
pnode_num = add_path_node(info, ret_pnode);
if (pnode_num < 0) {
- MSM_BUS_DBG("Error adding path node\n");
+ MSM_BUS_ERR("Error adding path node\n");
return -ENXIO;
}
next_pnode_id = CREATE_PNODE_ID(
@@ -213,24 +223,20 @@
info = fabnodeinfo->info;
ret_pnode = getpath(info->
node_info->priv_id, dest);
- if (ret_pnode >= 0) {
- pnode_num = add_path_node(info,
- ret_pnode);
- if (pnode_num < 0) {
- MSM_BUS_ERR("Malloc"
- "failure in adding"
- "path node\n");
- return -ENXIO;
- }
- next_pnode_id = CREATE_PNODE_ID(
- info->node_info->priv_id,
- pnode_num);
- break;
+ pnode_num = add_path_node(info,
+ ret_pnode);
+ if (pnode_num < 0) {
+ MSM_BUS_ERR("Malloc failure in"
+ " adding path node\n");
+ return -ENXIO;
}
+ next_pnode_id = CREATE_PNODE_ID(
+ info->node_info->priv_id, pnode_num);
+ break;
}
}
if (next_pnode_id < 0)
- return -EPERM;
+ return -ENXIO;
}
}
@@ -242,8 +248,9 @@
info = fabdev->algo->find_node(fabdev, src);
if (!info) {
MSM_BUS_ERR("Node info not found.\n");
- return -EPERM;
+ return -ENXIO;
}
+
pnode_num = add_path_node(info, next_pnode_id);
MSM_BUS_DBG(" Last: %d[%d] = (%d, %d)\n",
src, info->num_pnodes, GET_NODE(next_pnode_id),
@@ -466,12 +473,24 @@
}
src = msm_bus_board_get_iid(pdata->usecase->vectors[i].src);
+ if (src == -ENXIO) {
+ MSM_BUS_ERR("Master %d not supported. Client cannot be"
+ " registered\n",
+ pdata->usecase->vectors[i].src);
+ goto err;
+ }
dest = msm_bus_board_get_iid(pdata->usecase->vectors[i].dst);
+ if (dest == -ENXIO) {
+ MSM_BUS_ERR("Slave %d not supported. Client cannot be"
+ " registered\n",
+ pdata->usecase->vectors[i].dst);
+ goto err;
+ }
srcfab = msm_bus_get_fabric_device(GET_FABID(src));
srcfab->visited = true;
pnode[i] = getpath(src, dest);
bus_for_each_dev(&msm_bus_type, NULL, NULL, clearvisitedflag);
- if (pnode[i] < 0) {
+ if (pnode[i] == -ENXIO) {
MSM_BUS_ERR("Cannot register client now! Try again!\n");
goto err;
}
@@ -532,6 +551,20 @@
for (i = 0; i < pdata->usecase->num_paths; i++) {
src = msm_bus_board_get_iid(client->pdata->usecase[index].
vectors[i].src);
+ if (src == -ENXIO) {
+ MSM_BUS_ERR("Master %d not supported. Request cannot"
+ " be updated\n", client->pdata->usecase->
+ vectors[i].src);
+ goto err;
+ }
+
+ if (msm_bus_board_get_iid(client->pdata->usecase[index].
+ vectors[i].dst) == -ENXIO) {
+ MSM_BUS_ERR("Slave %d not supported. Request cannot"
+ " be updated\n", client->pdata->usecase->
+ vectors[i].dst);
+ }
+
pnode = client->src_pnode[i];
req_clk = client->pdata->usecase[index].vectors[i].ib;
req_bw = client->pdata->usecase[index].vectors[i].ab;
@@ -584,6 +617,7 @@
MSM_BUS_ERR("Cannot find node info!\n");
return -ENXIO;
}
+
MSM_BUS_DBG("Starting the loop--remove\n");
do {
struct msm_bus_inode_info *hop;
diff --git a/arch/arm/mach-msm/msm_bus/msm_bus_board_8660.c b/arch/arm/mach-msm/msm_bus/msm_bus_board_8660.c
index d284b70..fc91291 100644
--- a/arch/arm/mach-msm/msm_bus/msm_bus_board_8660.c
+++ b/arch/arm/mach-msm/msm_bus/msm_bus_board_8660.c
@@ -826,8 +826,14 @@
static int msm_bus_board_8660_get_iid(int id)
{
- return ((id < SLAVE_ID_KEY) ? master_iids[id] : slave_iids[id -
- SLAVE_ID_KEY]);
+ if ((id < SLAVE_ID_KEY && id >= NMASTERS) ||
+ id >= (SLAVE_ID_KEY + NSLAVES)) {
+ MSM_BUS_ERR("Cannot get iid. Invalid id %d passed\n", id);
+ return -EINVAL;
+ }
+
+ return CHECK_ID(((id < SLAVE_ID_KEY) ? master_iids[id] :
+ slave_iids[id - SLAVE_ID_KEY]), id);
}
static struct msm_bus_board_algorithm msm_bus_board_algo = {
diff --git a/arch/arm/mach-msm/msm_bus/msm_bus_board_8960.c b/arch/arm/mach-msm/msm_bus/msm_bus_board_8960.c
index 1dda082..97a3145 100644
--- a/arch/arm/mach-msm/msm_bus/msm_bus_board_8960.c
+++ b/arch/arm/mach-msm/msm_bus/msm_bus_board_8960.c
@@ -859,8 +859,8 @@
return -EINVAL;
}
- return ((id < SLAVE_ID_KEY) ? master_iids[id] : slave_iids[id -
- SLAVE_ID_KEY]);
+ return CHECK_ID(((id < SLAVE_ID_KEY) ? master_iids[id] :
+ slave_iids[id - SLAVE_ID_KEY]), id);
}
static struct msm_bus_board_algorithm msm_bus_board_algo = {