aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorMatt Redfearn <matt.redfearn@imgtec.com>2016-10-17 11:48:58 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-10-18 18:03:35 -0400
commit0f57dc6ae1ff0c702450083176b657ba37c07363 (patch)
tree280b82042a08c02dbb0622830d55ac2434fbdb89 /drivers/remoteproc
parent1001354ca34179f3db924eb66672442a173147dc (diff)
remoteproc: Keep local copy of firmware name
Storage of the firmware name was inconsistent, either storing a pointer to a name stored with unknown ownership, or a variable length tacked onto the end of the struct proc allocated in rproc_alloc. In preparation for allowing the firmware of an already allocated struct rproc to be changed, instead always keep a locally maintained copy of the firmware name. Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index c6bfb3496684..ccc2a73e94dd 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1273,6 +1273,7 @@ static void rproc_type_release(struct device *dev)
1273 if (rproc->index >= 0) 1273 if (rproc->index >= 0)
1274 ida_simple_remove(&rproc_dev_index, rproc->index); 1274 ida_simple_remove(&rproc_dev_index, rproc->index);
1275 1275
1276 kfree(rproc->firmware);
1276 kfree(rproc); 1277 kfree(rproc);
1277} 1278}
1278 1279
@@ -1310,31 +1311,31 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
1310{ 1311{
1311 struct rproc *rproc; 1312 struct rproc *rproc;
1312 char *p, *template = "rproc-%s-fw"; 1313 char *p, *template = "rproc-%s-fw";
1313 int name_len = 0; 1314 int name_len;
1314 1315
1315 if (!dev || !name || !ops) 1316 if (!dev || !name || !ops)
1316 return NULL; 1317 return NULL;
1317 1318
1318 if (!firmware) 1319 if (!firmware) {
1319 /* 1320 /*
1320 * Make room for default firmware name (minus %s plus '\0').
1321 * If the caller didn't pass in a firmware name then 1321 * If the caller didn't pass in a firmware name then
1322 * construct a default name. We're already glomming 'len' 1322 * construct a default name.
1323 * bytes onto the end of the struct rproc allocation, so do
1324 * a few more for the default firmware name (but only if
1325 * the caller doesn't pass one).
1326 */ 1323 */
1327 name_len = strlen(name) + strlen(template) - 2 + 1; 1324 name_len = strlen(name) + strlen(template) - 2 + 1;
1328 1325 p = kmalloc(name_len, GFP_KERNEL);
1329 rproc = kzalloc(sizeof(*rproc) + len + name_len, GFP_KERNEL); 1326 if (!p)
1330 if (!rproc) 1327 return NULL;
1331 return NULL;
1332
1333 if (!firmware) {
1334 p = (char *)rproc + sizeof(struct rproc) + len;
1335 snprintf(p, name_len, template, name); 1328 snprintf(p, name_len, template, name);
1336 } else { 1329 } else {
1337 p = (char *)firmware; 1330 p = kstrdup(firmware, GFP_KERNEL);
1331 if (!p)
1332 return NULL;
1333 }
1334
1335 rproc = kzalloc(sizeof(struct rproc) + len, GFP_KERNEL);
1336 if (!rproc) {
1337 kfree(p);
1338 return NULL;
1338 } 1339 }
1339 1340
1340 rproc->firmware = p; 1341 rproc->firmware = p;