2020-10-16 14:13:50

by kernel test robot

[permalink] [raw]
Subject: arch/mips/include/asm/addrspace.h:88:37: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9ff9b0d392ea08090cd1780fb196f36dbb586529
commit: 3af5f0f5c74ecbaf757ef06c3f80d56751277637 net: korina: fix kfree of rx/tx descriptor array
date: 4 days ago
config: mips-rb532_defconfig (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3af5f0f5c74ecbaf757ef06c3f80d56751277637
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 3af5f0f5c74ecbaf757ef06c3f80d56751277637
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from arch/mips/include/asm/barrier.h:11,
from arch/mips/include/asm/bitops.h:19,
from include/linux/bitops.h:29,
from include/linux/kernel.h:12,
from include/linux/list.h:9,
from include/linux/module.h:12,
from drivers/net/ethernet/korina.c:36:
drivers/net/ethernet/korina.c: In function 'korina_probe':
>> arch/mips/include/asm/addrspace.h:88:37: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast [-Wint-conversion]
88 | #define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
| ~~~~~~~~~~~~~~^~~~~~~~
| |
| unsigned int
drivers/net/ethernet/korina.c:1116:8: note: in expansion of macro 'KSEG0ADDR'
1116 | kfree(KSEG0ADDR(lp->td_ring));
| ^~~~~~~~~
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:13,
from arch/mips/include/asm/hardirq.h:16,
from include/linux/hardirq.h:10,
from include/linux/interrupt.h:11,
from drivers/net/ethernet/korina.c:42:
include/linux/slab.h:185:12: note: expected 'const void *' but argument is of type 'unsigned int'
185 | void kfree(const void *);
| ^~~~~~~~~~~~
In file included from arch/mips/include/asm/barrier.h:11,
from arch/mips/include/asm/bitops.h:19,
from include/linux/bitops.h:29,
from include/linux/kernel.h:12,
from include/linux/list.h:9,
from include/linux/module.h:12,
from drivers/net/ethernet/korina.c:36:
drivers/net/ethernet/korina.c: In function 'korina_remove':
>> arch/mips/include/asm/addrspace.h:88:37: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast [-Wint-conversion]
88 | #define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
| ~~~~~~~~~~~~~~^~~~~~~~
| |
| unsigned int
drivers/net/ethernet/korina.c:1136:8: note: in expansion of macro 'KSEG0ADDR'
1136 | kfree(KSEG0ADDR(lp->td_ring));
| ^~~~~~~~~
In file included from include/linux/irq.h:21,
from include/asm-generic/hardirq.h:13,
from arch/mips/include/asm/hardirq.h:16,
from include/linux/hardirq.h:10,
from include/linux/interrupt.h:11,
from drivers/net/ethernet/korina.c:42:
include/linux/slab.h:185:12: note: expected 'const void *' but argument is of type 'unsigned int'
185 | void kfree(const void *);
| ^~~~~~~~~~~~

vim +/kfree +88 arch/mips/include/asm/addrspace.h

^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 84
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 85 /*
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 86 * Map an address to a certain kernel segment
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 87 */
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 @88 #define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 89 #define KSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 90 #define KSEG2ADDR(a) (CPHYSADDR(a) | KSEG2)
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 91 #define KSEG3ADDR(a) (CPHYSADDR(a) | KSEG3)
^1da177e4c3f415 include/asm-mips/addrspace.h Linus Torvalds 2005-04-16 92

:::::: The code at line 88 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <[email protected]>
:::::: CC: Linus Torvalds <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (5.36 kB)
.config.gz (15.65 kB)
Download all attachments

2020-10-16 16:10:53

by Jakub Kicinski

[permalink] [raw]
Subject: Re: arch/mips/include/asm/addrspace.h:88:37: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast

On Fri, 16 Oct 2020 18:04:29 +0800 kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 9ff9b0d392ea08090cd1780fb196f36dbb586529
> commit: 3af5f0f5c74ecbaf757ef06c3f80d56751277637 net: korina: fix kfree of rx/tx descriptor array
> date: 4 days ago
> config: mips-rb532_defconfig (attached as .config)
> compiler: mipsel-linux-gcc (GCC) 9.3.0
> reproduce (this is a W=1 build):
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3af5f0f5c74ecbaf757ef06c3f80d56751277637
> git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> git fetch --no-tags linus master
> git checkout 3af5f0f5c74ecbaf757ef06c3f80d56751277637
> # save the attached .config to linux build tree
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=mips
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <[email protected]>
>
> All warnings (new ones prefixed by >>):
>
> In file included from arch/mips/include/asm/barrier.h:11,
> from arch/mips/include/asm/bitops.h:19,
> from include/linux/bitops.h:29,
> from include/linux/kernel.h:12,
> from include/linux/list.h:9,
> from include/linux/module.h:12,
> from drivers/net/ethernet/korina.c:36:
> drivers/net/ethernet/korina.c: In function 'korina_probe':
> >> arch/mips/include/asm/addrspace.h:88:37: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast [-Wint-conversion]
> 88 | #define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
> | ~~~~~~~~~~~~~~^~~~~~~~
> | |
> | unsigned int
> drivers/net/ethernet/korina.c:1116:8: note: in expansion of macro 'KSEG0ADDR'
> 1116 | kfree(KSEG0ADDR(lp->td_ring));
> | ^~~~~~~~~

Valentin, looks like we're missing a cast to (void *) or some other
pointer.. Would you mind sending a fix? You can find cross compilers
to test it here, cause this probably only builds for MIPS:

https://mirrors.edge.kernel.org/pub/tools/crosstool/

2020-10-16 20:10:06

by Valentin Vidić

[permalink] [raw]
Subject: Re: arch/mips/include/asm/addrspace.h:88:37: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast

On Fri, Oct 16, 2020 at 08:02:51AM -0700, Jakub Kicinski wrote:
> Valentin, looks like we're missing a cast to (void *) or some other
> pointer.. Would you mind sending a fix? You can find cross compilers
> to test it here, cause this probably only builds for MIPS:
>
> https://mirrors.edge.kernel.org/pub/tools/crosstool/

Ahh sorry about this, will try to setup cross compiler over the weekend
and check the warning.

--
Valentin

2020-10-18 19:11:09

by Valentin Vidić

[permalink] [raw]
Subject: [PATCH] net: korina: cast KSEG0 address to pointer in kfree

Fixes gcc warning:

passing argument 1 of 'kfree' makes pointer from integer without a cast

Fixes: 3af5f0f5c74e ("net: korina: fix kfree of rx/tx descriptor array")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Valentin Vidic <[email protected]>
---
drivers/net/ethernet/korina.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/korina.c b/drivers/net/ethernet/korina.c
index af441d699a57..bf48f0ded9c7 100644
--- a/drivers/net/ethernet/korina.c
+++ b/drivers/net/ethernet/korina.c
@@ -1113,7 +1113,7 @@ static int korina_probe(struct platform_device *pdev)
return rc;

probe_err_register:
- kfree(KSEG0ADDR(lp->td_ring));
+ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));
probe_err_td_ring:
iounmap(lp->tx_dma_regs);
probe_err_dma_tx:
@@ -1133,7 +1133,7 @@ static int korina_remove(struct platform_device *pdev)
iounmap(lp->eth_regs);
iounmap(lp->rx_dma_regs);
iounmap(lp->tx_dma_regs);
- kfree(KSEG0ADDR(lp->td_ring));
+ kfree((struct dma_desc *)KSEG0ADDR(lp->td_ring));

unregister_netdev(bif->dev);
free_netdev(bif->dev);
--
2.20.1

2020-10-20 18:16:42

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] net: korina: cast KSEG0 address to pointer in kfree

On Sun, 18 Oct 2020 20:42:55 +0200 Valentin Vidic wrote:
> Fixes gcc warning:
>
> passing argument 1 of 'kfree' makes pointer from integer without a cast
>
> Fixes: 3af5f0f5c74e ("net: korina: fix kfree of rx/tx descriptor array")
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: Valentin Vidic <[email protected]>

Applied, thank you!