* [linux-next:master 1161/2655] drivers/soc/mediatek/mtk-svs.c:1740 svs_get_efuse_data() warn: passing zero to 'PTR_ERR'
@ 2023-03-13 4:48 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2023-03-13 4:48 UTC (permalink / raw)
To: oe-kbuild, Roger Lu; +Cc: lkp, oe-kbuild-all, Matthias Brugger
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 24469a0e5052ba01a35a15f104717a82b7a4798b
commit: 9f195f3a1e696b6576988c1e58fa7389beae3351 [1161/2655] soc: mediatek: mtk-svs: use svs get efuse common function
config: s390-randconfig-m031-20230310 (https://download.01.org/0day-ci/archive/20230312/202303120758.x4oFgtr4-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202303120758.x4oFgtr4-lkp@intel.com/
New smatch warnings:
drivers/soc/mediatek/mtk-svs.c:1740 svs_get_efuse_data() warn: passing zero to 'PTR_ERR'
Old smatch warnings:
drivers/soc/mediatek/mtk-svs.c:1742 svs_get_efuse_data() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +1740 drivers/soc/mediatek/mtk-svs.c
9f195f3a1e696b Roger Lu 2023-02-02 1732 static int svs_get_efuse_data(struct svs_platform *svsp,
9f195f3a1e696b Roger Lu 2023-02-02 1733 const char *nvmem_cell_name,
9f195f3a1e696b Roger Lu 2023-02-02 1734 u32 **svsp_efuse, size_t *svsp_efuse_max)
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1735 {
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1736 struct nvmem_cell *cell;
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1737
9f195f3a1e696b Roger Lu 2023-02-02 1738 cell = nvmem_cell_get(svsp->dev, nvmem_cell_name);
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1739 if (IS_ERR_OR_NULL(cell)) {
9f195f3a1e696b Roger Lu 2023-02-02 @1740 dev_err(svsp->dev, "no \"%s\"? %ld\n",
9f195f3a1e696b Roger Lu 2023-02-02 1741 nvmem_cell_name, PTR_ERR(cell));
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1742 return PTR_ERR(cell);
I guess this warning is showing up as new because you renamed the
svs_get_efuse_data() function.
The bug is that if nvmem_cell_get() returns NULL then the return is not
handled correctly. But nvmem_cell_get() never returns NULL. So it's
bad code, but in run time the bug is impossible to hit.
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1743 }
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1744
9f195f3a1e696b Roger Lu 2023-02-02 1745 *svsp_efuse = nvmem_cell_read(cell, svsp_efuse_max);
9f195f3a1e696b Roger Lu 2023-02-02 1746 if (IS_ERR(*svsp_efuse)) {
9f195f3a1e696b Roger Lu 2023-02-02 1747 dev_err(svsp->dev, "cannot read \"%s\" efuse: %ld\n",
9f195f3a1e696b Roger Lu 2023-02-02 1748 nvmem_cell_name, PTR_ERR(*svsp_efuse));
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1749 nvmem_cell_put(cell);
9f195f3a1e696b Roger Lu 2023-02-02 1750 return PTR_ERR(*svsp_efuse);
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1751 }
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1752
9f195f3a1e696b Roger Lu 2023-02-02 1753 *svsp_efuse_max /= sizeof(u32);
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1754 nvmem_cell_put(cell);
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1755
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1756 return 0;
43819e38533066 AngeloGioacchino Del Regno 2022-08-25 1757 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-13 4:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 4:48 [linux-next:master 1161/2655] drivers/soc/mediatek/mtk-svs.c:1740 svs_get_efuse_data() warn: passing zero to 'PTR_ERR' Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).