Skip to content

Commit

Permalink
bus: arm-ccn: Check memory allocation failure
Browse files Browse the repository at this point in the history
Check memory allocation failures and return -ENOMEM in such cases

This avoids a potential NULL pointer dereference.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Scott Branden <scott.branden@broadcom.com>
Cc: stable@vger.kernel.org # 3.17+
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
  • Loading branch information
Christophe JAILLET authored and Pawel Moll committed Dec 4, 2017
1 parent 8a84bf4 commit 2477117
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/bus/arm-ccn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,10 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)
int len = snprintf(NULL, 0, "ccn_%d", ccn->dt.id);

name = devm_kzalloc(ccn->dev, len + 1, GFP_KERNEL);
if (!name) {
err = -ENOMEM;
goto error_choose_name;
}
snprintf(name, len + 1, "ccn_%d", ccn->dt.id);
}

Expand Down Expand Up @@ -1319,6 +1323,7 @@ static int arm_ccn_pmu_init(struct arm_ccn *ccn)

error_pmu_register:
error_set_affinity:
error_choose_name:
ida_simple_remove(&arm_ccn_pmu_ida, ccn->dt.id);
for (i = 0; i < ccn->num_xps; i++)
writel(0, ccn->xp[i].base + CCN_XP_DT_CONTROL);
Expand Down

0 comments on commit 2477117

Please sign in to comment.