lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 20 Apr 2020 18:56:14 -0700
From:   Bjorn Andersson <bjorn.andersson@...aro.org>
To:     Mathieu Poirier <mathieu.poirier@...aro.org>
Cc:     ohad@...ery.com, elder@...aro.org, s-anna@...com,
        Markus.Elfring@....de, linux-remoteproc@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/4] remoteproc: Use kstrdup_const() rather than
 kstrdup()

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@...aro.org>
> Signed-off-by: Mathieu Poirier <mathieu.poirier@...aro.org>
> Reviewed-by: Alex Elder <elder@...aro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@...aro.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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ