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:   Fri, 20 Oct 2017 15:34:18 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     srinivas.kandagatla@...aro.org
Cc:     linux-kernel@...r.kernel.org,
        Masahiro Yamada <yamada.masahiro@...ionext.com>
Subject: Re: [PATCH 03/12] nvmem: mtk-efuse: fix different address space
 warnings of sparse

On Mon, Oct 09, 2017 at 03:26:32PM +0200, srinivas.kandagatla@...aro.org wrote:
> From: Masahiro Yamada <yamada.masahiro@...ionext.com>
> 
> Fix the following sparse warnings:
> 
> drivers/nvmem/mtk-efuse.c:24:30: warning: incorrect type in initializer (different address spaces)
> drivers/nvmem/mtk-efuse.c:24:30:    expected void [noderef] <asn:2>*base
> drivers/nvmem/mtk-efuse.c:24:30:    got void *context
> drivers/nvmem/mtk-efuse.c:37:30: warning: incorrect type in initializer (different address spaces)
> drivers/nvmem/mtk-efuse.c:37:30:    expected void [noderef] <asn:2>*base
> drivers/nvmem/mtk-efuse.c:37:30:    got void *context
> drivers/nvmem/mtk-efuse.c:69:23: warning: incorrect type in assignment (different address spaces)
> drivers/nvmem/mtk-efuse.c:69:23:    expected void *priv
> drivers/nvmem/mtk-efuse.c:69:23:    got void [noderef] <asn:2>*[assigned] base
> 
> The type of nvmem_config->priv is (void *), so sparse complains
> about assignment of the base address with (void __iomem *) type.
> 
> Even if we cast it out, sparse still warns:
> warning: cast removes address space of expression
> 
> Of course, we can shut up the sparse by marking __force, but a more
> correct way is to put the base address into driver private data.

Ick, no, really?

That's horrid.  Do the __force cast as that is what you are really doing
here, and it is good to see the bad use of it (hint, perhaps the api
needs to be fixed up so you do not have to do that???)



> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
> ---
>  drivers/nvmem/mtk-efuse.c | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/nvmem/mtk-efuse.c b/drivers/nvmem/mtk-efuse.c
> index fa7a0f66b37e..c4058b598703 100644
> --- a/drivers/nvmem/mtk-efuse.c
> +++ b/drivers/nvmem/mtk-efuse.c
> @@ -18,15 +18,19 @@
>  #include <linux/nvmem-provider.h>
>  #include <linux/platform_device.h>
>  
> +struct mtk_efuse_priv {
> +	void __iomem *base;
> +};
> +
>  static int mtk_reg_read(void *context,


Make the read call take a __iomem *, not a random void *.  That should
solve this issue, right?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ