diff options
| author | Dhoat Harpal <hdhoat@codeaurora.org> | 2016-11-08 15:00:20 +0530 |
|---|---|---|
| committer | Dhoat Harpal <hdhoat@codeaurora.org> | 2016-11-28 18:12:44 +0530 |
| commit | 6bf0e69ea6c238837703ea6a1fa6c4e1bcf8dbf6 (patch) | |
| tree | d0b9d11f7deb2abfb9f0a8037b79cc1bb1a41383 | |
| parent | 9aa1df0cf5ffb58b52b55b4fe2ea6531f795e186 (diff) | |
soc: qcom: glink: add NULL check for edge_ctx
In function edge_name_to_ctx_create, NULL check is missing after
kzalloc for edge_ctx variable.
NULL check validation is added.
CRs-Fixed: 1086686
Change-Id: Icbffbd9d02df97bda531353c41a7025b95a53991
Signed-off-by: Dhoat Harpal <hdhoat@codeaurora.org>
| -rw-r--r-- | drivers/soc/qcom/glink.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/soc/qcom/glink.c b/drivers/soc/qcom/glink.c index 382245eb90b6..21ff179b7c0b 100644 --- a/drivers/soc/qcom/glink.c +++ b/drivers/soc/qcom/glink.c @@ -1058,7 +1058,8 @@ static void glink_edge_ctx_release(struct rwref_lock *ch_st_lock) * it is not found. * @xprt_ctx: Transport to search for a matching edge. * - * Return: The edge ctx corresponding to edge of @xprt_ctx. + * Return: The edge ctx corresponding to edge of @xprt_ctx or + * NULL if memory allocation fails. */ static struct glink_core_edge_ctx *edge_name_to_ctx_create( struct glink_core_xprt_ctx *xprt_ctx) @@ -1074,6 +1075,10 @@ static struct glink_core_edge_ctx *edge_name_to_ctx_create( } } edge_ctx = kzalloc(sizeof(struct glink_core_edge_ctx), GFP_KERNEL); + if (!edge_ctx) { + mutex_unlock(&edge_list_lock_lhd0); + return NULL; + } strlcpy(edge_ctx->name, xprt_ctx->edge, GLINK_NAME_SIZE); rwref_lock_init(&edge_ctx->edge_ref_lock_lhd1, glink_edge_ctx_release); mutex_init(&edge_ctx->edge_migration_lock_lhd2); @@ -3909,6 +3914,10 @@ int glink_core_register_transport(struct glink_transport_if *if_ptr, xprt_ptr->local_version_idx = cfg->versions_entries - 1; xprt_ptr->remote_version_idx = cfg->versions_entries - 1; xprt_ptr->edge_ctx = edge_name_to_ctx_create(xprt_ptr); + if (!xprt_ptr->edge_ctx) { + kfree(xprt_ptr); + return -ENOMEM; + } xprt_ptr->l_features = cfg->versions[cfg->versions_entries - 1].features; if (!if_ptr->poll) |
