Skip to contentSkip to conversation

FAILED: patch "[PATCH] bus: arm-ccn: Check memory allocation failure" failed to apply to 3.18-stable tree

PATCH [email protected] 1 participant 1 message Dec 11, 2017 Stable branch

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 3.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

Quoted 1 line

From 24771179c5c138f0ea3ef88b7972979f62f2d5db Mon Sep 17 00:00:00 2001

From: Christophe JAILLET <[email protected]>
Date: Sun, 27 Aug 2017 11:06:50 +0100
Subject: [PATCH] bus: arm-ccn: Check memory allocation failure

Check memory allocation failures and return -ENOMEM in such cases

This avoids a potential NULL pointer dereference.

drivers/bus/arm-ccn.c +5 -0
index 7625bf762acb..a7951662f85b 100644
@@ -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);
 	}
 
@@ -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);