Hello Julia,
Thanks for report this.
在 2020/8/3 下午9:26, Julia Lawall 写道:
Hello,
priv can't be kfreed because it was allocated with a devm function.
julia
---------- Forwarded message ----------
Date: Mon, 3 Aug 2020 21:16:25 +0800
From: kernel test robot <lkp@xxxxxxxxx>
To: kbuild@xxxxxxxxxxxx
Cc: lkp@xxxxxxxxx, Julia Lawall <julia.lawall@xxxxxxx>
Subject: [crypto:master 164/167] drivers/char/hw_random/ingenic-rng.c:118:1-6:
WARNING: invalid free of devm_ allocated data
CC: kbuild-all@xxxxxxxxxxxx
CC: linux-crypto@xxxxxxxxxxxxxxx
TO: "周琰杰 (Zhou Yanjie)" <zhouyanjie@xxxxxxxxxxxxxx>
CC: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
CC: PrasannaKumar Muralidharan <prasannatsmkumar@xxxxxxxxx>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git master
head: 3cbfe80737c18ac6e635421ab676716a393d3074
commit: 190873a0ea4500433ae818521cad20d37f9ee059 [164/167] crypto: ingenic - Add hardware RNG for Ingenic JZ4780 and X1000
:::::: branch date: 3 days ago
:::::: commit date: 3 days ago
config: mips-randconfig-c003-20200803 (attached as .config)
compiler: mipsel-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Julia Lawall <julia.lawall@xxxxxxx>
coccinelle warnings: (new ones prefixed by >>)
drivers/char/hw_random/ingenic-rng.c:118:1-6: WARNING: invalid free of devm_ allocated data
# https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git/commit/?id=190873a0ea4500433ae818521cad20d37f9ee059
git remote add crypto https://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6.git
git remote update crypto
git checkout 190873a0ea4500433ae818521cad20d37f9ee059
vim +118 drivers/char/hw_random/ingenic-rng.c
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 82)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 83) static int ingenic_rng_probe(struct platform_device *pdev)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 84) {
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 85) struct ingenic_rng *priv;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 86) int ret;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 87)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 88) priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 89) if (!priv)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 90) return -ENOMEM;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 91)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 92) priv->base = devm_platform_ioremap_resource(pdev, 0);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 93) if (IS_ERR(priv->base)) {
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 94) pr_err("%s: Failed to map RNG registers\n", __func__);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 95) ret = PTR_ERR(priv->base);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 96) goto err_free_rng;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 97) }
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 98)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 99) priv->version = (enum ingenic_rng_version)of_device_get_match_data(&pdev->dev);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 100)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 101) priv->rng.name = pdev->name;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 102) priv->rng.init = ingenic_rng_init;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 103) priv->rng.cleanup = ingenic_rng_cleanup;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 104) priv->rng.read = ingenic_rng_read;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 105)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 106) ret = hwrng_register(&priv->rng);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 107) if (ret) {
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 108) dev_err(&pdev->dev, "Failed to register hwrng\n");
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 109) goto err_free_rng;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 110) }
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 111)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 112) platform_set_drvdata(pdev, priv);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 113)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 114) dev_info(&pdev->dev, "Ingenic RNG driver registered\n");
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 115) return 0;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 116)
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 117) err_free_rng:
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 @118) kfree(priv);
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 119) return ret;
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 120) }
190873a0ea4500 周琰杰 (Zhou Yanjie 2020-07-23 121)
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx