Re: drivers/char/hw_random/jh7110-trng.c:303 starfive_trng_probe() warn: passing zero to 'dev_err_probe'

From: Jia Jie Ho
Date: Mon Nov 20 2023 - 10:02:25 EST


On 20/11/2023 10:22 pm, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: c42d9eeef8e5ba9292eda36fd8e3c11f35ee065c
> commit: c388f458bc34eb3a5728b67f6614f9375cd99087 hwrng: starfive - Add TRNG driver for StarFive SoC
> config: riscv-randconfig-r071-20231112 (https://download.01.org/0day-ci/archive/20231116/202311160649.3GhKCfhd-lkp@xxxxxxxxx/config)
> compiler: riscv64-linux-gcc (GCC) 13.2.0
> reproduce: (https://download.01.org/0day-ci/archive/20231116/202311160649.3GhKCfhd-lkp@xxxxxxxxx/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
> | Reported-by: Dan Carpenter <error27@xxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202311160649.3GhKCfhd-lkp@xxxxxxxxx/
>
> smatch warnings:
> drivers/char/hw_random/jh7110-trng.c:303 starfive_trng_probe() warn: passing zero to 'dev_err_probe'
>
> vim +/dev_err_probe +303 drivers/char/hw_random/jh7110-trng.c
>
> c388f458bc34eb Jia Jie Ho 2023-01-17 274 static int starfive_trng_probe(struct platform_device *pdev)
> c388f458bc34eb Jia Jie Ho 2023-01-17 275 {
> c388f458bc34eb Jia Jie Ho 2023-01-17 276 int ret;
> c388f458bc34eb Jia Jie Ho 2023-01-17 277 int irq;
> c388f458bc34eb Jia Jie Ho 2023-01-17 278 struct starfive_trng *trng;
> c388f458bc34eb Jia Jie Ho 2023-01-17 279
> c388f458bc34eb Jia Jie Ho 2023-01-17 280 trng = devm_kzalloc(&pdev->dev, sizeof(*trng), GFP_KERNEL);
> c388f458bc34eb Jia Jie Ho 2023-01-17 281 if (!trng)
> c388f458bc34eb Jia Jie Ho 2023-01-17 282 return -ENOMEM;
> c388f458bc34eb Jia Jie Ho 2023-01-17 283
> c388f458bc34eb Jia Jie Ho 2023-01-17 284 platform_set_drvdata(pdev, trng);
> c388f458bc34eb Jia Jie Ho 2023-01-17 285 trng->dev = &pdev->dev;
> c388f458bc34eb Jia Jie Ho 2023-01-17 286
> c388f458bc34eb Jia Jie Ho 2023-01-17 287 trng->base = devm_platform_ioremap_resource(pdev, 0);
> c388f458bc34eb Jia Jie Ho 2023-01-17 288 if (IS_ERR(trng->base))
> c388f458bc34eb Jia Jie Ho 2023-01-17 289 return dev_err_probe(&pdev->dev, PTR_ERR(trng->base),
> c388f458bc34eb Jia Jie Ho 2023-01-17 290 "Error remapping memory for platform device.\n");
> c388f458bc34eb Jia Jie Ho 2023-01-17 291
> c388f458bc34eb Jia Jie Ho 2023-01-17 292 irq = platform_get_irq(pdev, 0);
> c388f458bc34eb Jia Jie Ho 2023-01-17 293 if (irq < 0)
> c388f458bc34eb Jia Jie Ho 2023-01-17 294 return irq;
> c388f458bc34eb Jia Jie Ho 2023-01-17 295
> c388f458bc34eb Jia Jie Ho 2023-01-17 296 init_completion(&trng->random_done);
> c388f458bc34eb Jia Jie Ho 2023-01-17 297 init_completion(&trng->reseed_done);
> c388f458bc34eb Jia Jie Ho 2023-01-17 298 spin_lock_init(&trng->write_lock);
> c388f458bc34eb Jia Jie Ho 2023-01-17 299
> c388f458bc34eb Jia Jie Ho 2023-01-17 300 ret = devm_request_irq(&pdev->dev, irq, starfive_trng_irq, 0, pdev->name,
> c388f458bc34eb Jia Jie Ho 2023-01-17 301 (void *)trng);
> c388f458bc34eb Jia Jie Ho 2023-01-17 302 if (ret)
> c388f458bc34eb Jia Jie Ho 2023-01-17 @303 return dev_err_probe(&pdev->dev, irq,
> ^^^
> Should be "ret". Weird how we're getting this warning in November when
> the code is from Jan... Looks like the bug is still their in linux-next
> though.
>

I'll submit a patch for this.

Thanks,
Jia Jie