summaryrefslogtreecommitdiff
path: root/drivers/remoteproc
diff options
context:
space:
mode:
authorMathieu Poirier <mathieu.poirier@linaro.org>2020-04-20 17:15:58 -0600
committerBjorn Andersson <bjorn.andersson@linaro.org>2020-04-20 19:29:29 -0700
commit1487deda19c82d30d1867277e89bc2d515b9d2d4 (patch)
tree97126b8e2f215d69b1193a1a20706bcdf07409aa /drivers/remoteproc
parent1f36ab3f6e3b791eadad94f792c874706e153b66 (diff)
downloadlwn-1487deda19c82d30d1867277e89bc2d515b9d2d4.tar.gz
lwn-1487deda19c82d30d1867277e89bc2d515b9d2d4.zip
remoteproc: Use kstrdup_const() rather than kstrdup()
For cases where @firmware is declared "const char *", use function kstrdup_const() to avoid needlessly creating another copy on the heap. Suggested-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Reviewed-by: Alex Elder <elder@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20200420231601.16781-2-mathieu.poirier@linaro.org Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/remoteproc')
-rw-r--r--drivers/remoteproc/remoteproc_core.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index d9e6949e4ac1..db8a15fc1e4a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1996,7 +1996,7 @@ static void rproc_type_release(struct device *dev)
if (rproc->index >= 0)
ida_simple_remove(&rproc_dev_index, rproc->index);
- kfree(rproc->firmware);
+ kfree_const(rproc->firmware);
kfree(rproc->ops);
kfree(rproc);
}
@@ -2009,7 +2009,7 @@ static const struct device_type rproc_type = {
static int rproc_alloc_firmware(struct rproc *rproc,
const char *name, const char *firmware)
{
- char *p;
+ const char *p;
if (!firmware)
/*
@@ -2018,7 +2018,7 @@ static int rproc_alloc_firmware(struct rproc *rproc,
*/
p = kasprintf(GFP_KERNEL, "rproc-%s-fw", name);
else
- p = kstrdup(firmware, GFP_KERNEL);
+ p = kstrdup_const(firmware, GFP_KERNEL);
if (!p)
return -ENOMEM;
@@ -2122,7 +2122,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
return rproc;
free_firmware:
- kfree(rproc->firmware);
+ kfree_const(rproc->firmware);
free_rproc:
kfree(rproc);
return NULL;