Commit 1487deda authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Bjorn Andersson

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: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20200420231601.16781-2-mathieu.poirier@linaro.orgSigned-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 1f36ab3f
...@@ -1996,7 +1996,7 @@ static void rproc_type_release(struct device *dev) ...@@ -1996,7 +1996,7 @@ static void rproc_type_release(struct device *dev)
if (rproc->index >= 0) if (rproc->index >= 0)
ida_simple_remove(&rproc_dev_index, rproc->index); ida_simple_remove(&rproc_dev_index, rproc->index);
kfree(rproc->firmware); kfree_const(rproc->firmware);
kfree(rproc->ops); kfree(rproc->ops);
kfree(rproc); kfree(rproc);
} }
...@@ -2009,7 +2009,7 @@ static const struct device_type rproc_type = { ...@@ -2009,7 +2009,7 @@ static const struct device_type rproc_type = {
static int rproc_alloc_firmware(struct rproc *rproc, static int rproc_alloc_firmware(struct rproc *rproc,
const char *name, const char *firmware) const char *name, const char *firmware)
{ {
char *p; const char *p;
if (!firmware) if (!firmware)
/* /*
...@@ -2018,7 +2018,7 @@ static int rproc_alloc_firmware(struct rproc *rproc, ...@@ -2018,7 +2018,7 @@ static int rproc_alloc_firmware(struct rproc *rproc,
*/ */
p = kasprintf(GFP_KERNEL, "rproc-%s-fw", name); p = kasprintf(GFP_KERNEL, "rproc-%s-fw", name);
else else
p = kstrdup(firmware, GFP_KERNEL); p = kstrdup_const(firmware, GFP_KERNEL);
if (!p) if (!p)
return -ENOMEM; return -ENOMEM;
...@@ -2122,7 +2122,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, ...@@ -2122,7 +2122,7 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
return rproc; return rproc;
free_firmware: free_firmware:
kfree(rproc->firmware); kfree_const(rproc->firmware);
free_rproc: free_rproc:
kfree(rproc); kfree(rproc);
return NULL; return NULL;
......
...@@ -489,7 +489,7 @@ struct rproc { ...@@ -489,7 +489,7 @@ struct rproc {
struct list_head node; struct list_head node;
struct iommu_domain *domain; struct iommu_domain *domain;
const char *name; const char *name;
char *firmware; const char *firmware;
void *priv; void *priv;
struct rproc_ops *ops; struct rproc_ops *ops;
struct device dev; struct device dev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment