From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: ohad@wizery.com, elder@linaro.org, s-anna@ti.com,
Markus.Elfring@web.de, linux-remoteproc@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/4] remoteproc: Use kstrdup_const() rather than kstrdup()
Date: Mon, 20 Apr 2020 18:56:14 -0700 [thread overview]
Message-ID: <20200421015614.GG1868936@builder.lan> (raw)
In-Reply-To: <20200420231601.16781-2-mathieu.poirier@linaro.org>
On Mon 20 Apr 16:15 PDT 2020, Mathieu Poirier wrote:
> 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>
> ---
> drivers/remoteproc/remoteproc_core.c | 8 ++++----
> include/linux/remoteproc.h | 2 +-
> 2 files changed, 5 insertions(+), 5 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;
> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> index 0547676479d3..800b4f09dc98 100644
> --- a/include/linux/remoteproc.h
> +++ b/include/linux/remoteproc.h
> @@ -489,7 +489,7 @@ struct rproc {
> struct list_head node;
> struct iommu_domain *domain;
> const char *name;
> - char *firmware;
> + const char *firmware;
> void *priv;
> struct rproc_ops *ops;
> struct device dev;
> --
> 2.20.1
>
next prev parent reply other threads:[~2020-04-21 1:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 23:15 [PATCH v3 0/4] remoteproc: Refactor function rproc_alloc() Mathieu Poirier
2020-04-20 23:15 ` [PATCH v3 1/4] remoteproc: Use kstrdup_const() rather than kstrdup() Mathieu Poirier
2020-04-21 1:56 ` Bjorn Andersson [this message]
2020-04-20 23:15 ` [PATCH v3 2/4] remoteproc: Restructure firmware name allocation Mathieu Poirier
2020-04-21 1:56 ` Bjorn Andersson
2020-04-20 23:16 ` [PATCH v3 3/4] remoteproc: Split rproc_ops allocation from rproc_alloc() Mathieu Poirier
2020-04-21 1:57 ` Bjorn Andersson
2020-04-20 23:16 ` [PATCH v3 4/4] remoteproc: Get rid of tedious error path Mathieu Poirier
2020-04-21 2:01 ` Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200421015614.GG1868936@builder.lan \
--to=bjorn.andersson@linaro.org \
--cc=Markus.Elfring@web.de \
--cc=elder@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=ohad@wizery.com \
--cc=s-anna@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox