Re: [PATCH v4 2/4] clk: mediatek: Provide mtk_devm_alloc_clk_data

From: Markus Schneider-Pargmann
Date: Mon Aug 29 2022 - 05:34:10 EST


Hi,

On Tue, Aug 23, 2022 at 07:44:26AM +0800, kernel test robot wrote:
> Hi Markus,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on clk/clk-next]
> [also build test WARNING on robh/for-next linus/master v6.0-rc2 next-20220822]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Markus-Schneider-Pargmann/clk-mediatek-Add-mt8365-support/20220822-233030
> base: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
> config: loongarch-randconfig-c004-20220821 (https://download.01.org/0day-ci/archive/20220823/202208230714.8DNW6JjZ-lkp@xxxxxxxxx/config)
> compiler: loongarch64-linux-gcc (GCC) 12.1.0
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/clk/mediatek/clk-mtk.c:64:1-6: WARNING: invalid free of devm_ allocated data
>
> vim +64 drivers/clk/mediatek/clk-mtk.c
>
> 9741b1a68035b54 James Liao 2015-04-23 61
> 609cc5e1a82394e Chen-Yu Tsai 2022-05-19 62 void mtk_free_clk_data(struct clk_hw_onecell_data *clk_data)
> 300796cad22153f Chun-Jie Chen 2021-09-14 63 {
> 300796cad22153f Chun-Jie Chen 2021-09-14 @64 kfree(clk_data);
> 300796cad22153f Chun-Jie Chen 2021-09-14 65 }
> 609cc5e1a82394e Chen-Yu Tsai 2022-05-19 66 EXPORT_SYMBOL_GPL(mtk_free_clk_data);

I don't see how this should be called with clk_data being initialized by
devm_*. Maybe I am bit code blind.

Do you have an actual call stack how this is supposed to happen? Also I
wasn't able to get the same warning with coccinelle (different
compiler).

Best,
Markus