linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: vc5: Add memory check to prevent oops
@ 2020-06-30 21:01 Adam Ford
  2020-07-01 11:06 ` kernel test robot
  2020-07-02 14:42 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Adam Ford @ 2020-06-30 21:01 UTC (permalink / raw)
  To: linux-clk
  Cc: dan.carpenter, aford, Adam Ford, Marek Vasut, Michael Turquette,
	Stephen Boyd, linux-kernel

When getting the names of the child nodes, kasprintf is used to
allocate memory which is used to create the string for the node
name.  Unfortunately, there is no memory check to determine
if this allocation fails, it may cause an error when trying
to get child node name.

This patch will check if the memory allocation fails, and returns
and -NOMEM error instead of blindly moving on.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Adam Ford <aford173@gmail.com>

diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c
index 1d8ee4b8b1f5..29cdb38dc40b 100644
--- a/drivers/clk/clk-versaclock5.c
+++ b/drivers/clk/clk-versaclock5.c
@@ -789,10 +789,14 @@ static int vc5_get_output_config(struct i2c_client *client,
 	int ret = 0;
 
 	child_name = kasprintf(GFP_KERNEL, "OUT%d", clk_out->num + 1);
+	if (!child_name) {
+		ret = -ENOMEM;
+		goto output_error;
+	}
 	np_output = of_get_child_by_name(client->dev.of_node, child_name);
 	kfree(child_name);
 	if (!np_output)
-		goto output_done;
+		return 0;
 
 	ret = vc5_update_mode(np_output, clk_out);
 	if (ret)
@@ -813,7 +817,6 @@ static int vc5_get_output_config(struct i2c_client *client,
 
 	of_node_put(np_output);
 
-output_done:
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: vc5: Add memory check to prevent oops
  2020-06-30 21:01 [PATCH] clk: vc5: Add memory check to prevent oops Adam Ford
@ 2020-07-01 11:06 ` kernel test robot
  2020-07-02 14:42 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-07-01 11:06 UTC (permalink / raw)
  To: Adam Ford, linux-clk
  Cc: kbuild-all, clang-built-linux, dan.carpenter, aford, Adam Ford,
	Marek Vasut, Michael Turquette, Stephen Boyd, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 33394 bytes --]

Hi Adam,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on clk/clk-next]
[also build test WARNING on next-20200701]
[cannot apply to v5.8-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Adam-Ford/clk-vc5-Add-memory-check-to-prevent-oops/20200701-050451
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project c8f1d442d0858f66fd4128fde6f67eb5202fa2b1)
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
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   ~~~ ^~~~~~~~~~~
   %u
   include/linux/dev_printk.h:104:32: note: expanded from macro 'dev_err'
   _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
   ~~~ ^~~~~~~~~~~
   drivers/soc/qcom/smem.c:852:47: warning: format specifies type 'unsigned short' but the argument has type 'unsigned int'
   dev_err(smem->dev, "duplicate host %hun", remote_host);
   ~~~ ^~~~~~~~~~~
   %u
   include/linux/dev_printk.h:104:32: note: expanded from macro 'dev_err'
   _dev_err(dev, dev_fmt(fmt), ##__VA_ARGS__)
   ~~~ ^~~~~~~~~~~
   1 warning generated.
   2 warnings generated.
   drivers/soc/qcom/smem.c:135: warning: Function parameter or member 'toc' not described in 'smem_header'
   drivers/soc/qcom/smem.c:275: warning: Function parameter or member 'socinfo' not described in 'qcom_smem'
   2 warnings generated.
   drivers/video/of_videomode.c:32: warning: Function parameter or member 'np' not described in 'of_get_videomode'
   drivers/video/of_videomode.c:32: warning: Function parameter or member 'vm' not described in 'of_get_videomode'
   drivers/video/of_videomode.c:32: warning: Function parameter or member 'index' not described in 'of_get_videomode'
   drivers/soc/renesas/rmobile-sysc.c:206:22: warning: cast to smaller integer type 'enum pd_types' from 'const void
   add_special_pd(np, (enum pd_types)id->data);
   ^~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.
   drivers/pinctrl/bcm/pinctrl-iproc-gpio.c:141: warning: Function parameter or member 'chip' not described in 'iproc_set_bit'
   drivers/pinctrl/bcm/pinctrl-iproc-gpio.c:141: warning: Excess function parameter 'iproc_gpio' description in 'iproc_set_bit'
   drivers/soc/qcom/smp2p.c:74: warning: Function parameter or member 'flags' not described in 'smp2p_smem_item'
   drivers/soc/qcom/smp2p.c:149: warning: Function parameter or member 'out' not described in 'qcom_smp2p'
   drivers/soc/qcom/smsm.c:140: warning: Function parameter or member 'mask' not described in 'smsm_update_bits'
   drivers/soc/qcom/smsm.c:140: warning: Excess function parameter 'offset' description in 'smsm_update_bits'
   drivers/soc/qcom/smsm.c:257: warning: bad line:
   drivers/soc/qcom/smsm.c:260: warning: bad line:
   drivers/video/backlight/backlight.c:329: warning: Function parameter or member 'reason' not described in 'backlight_force_update'
   drivers/video/backlight/backlight.c:354: warning: Function parameter or member 'props' not described in 'backlight_device_register'
   drivers/iommu/intel/pasid.c:10: warning: Function parameter or member 'fmt' not described in 'pr_fmt'
   drivers/soc/qcom/wcnss_ctrl.c:81: warning: Function parameter or member 'major' not described in 'wcnss_version_resp'
   drivers/soc/qcom/wcnss_ctrl.c:81: warning: Function parameter or member 'minor' not described in 'wcnss_version_resp'
   drivers/soc/qcom/wcnss_ctrl.c:81: warning: Function parameter or member 'version' not described in 'wcnss_version_resp'
   drivers/soc/qcom/wcnss_ctrl.c:81: warning: Function parameter or member 'revision' not described in 'wcnss_version_resp'
   drivers/soc/qcom/wcnss_ctrl.c:122: warning: Function parameter or member 'rpdev' not described in 'wcnss_ctrl_smd_callback'
   drivers/soc/qcom/wcnss_ctrl.c:122: warning: Function parameter or member 'priv' not described in 'wcnss_ctrl_smd_callback'
   drivers/soc/qcom/wcnss_ctrl.c:122: warning: Function parameter or member 'addr' not described in 'wcnss_ctrl_smd_callback'
   drivers/soc/qcom/wcnss_ctrl.c:122: warning: Excess function parameter 'channel' description in 'wcnss_ctrl_smd_callback'
   drivers/soc/qcom/wcnss_ctrl.c:272: warning: Function parameter or member 'priv' not described in 'qcom_wcnss_open_channel'
   drivers/acpi/acpi_lpit.c:148:6: warning: no previous prototype for function 'acpi_init_lpit'
   void acpi_init_lpit(void)
   ^
   drivers/acpi/acpi_lpit.c:148:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void acpi_init_lpit(void)
   ^
   static
   1 warning generated.
   drivers/video/fbdev/riva/fbdev.c:489: warning: Function parameter or member 'data8' not described in 'rivafb_load_cursor_image'
   drivers/video/fbdev/riva/fbdev.c:489: warning: Excess function parameter 'data' description in 'rivafb_load_cursor_image'
   drivers/video/fbdev/riva/fbdev.c:867: warning: Function parameter or member 'var' not described in 'rivafb_do_maximize'
   drivers/video/fbdev/riva/fbdev.c:867: warning: Function parameter or member 'nom' not described in 'rivafb_do_maximize'
   drivers/video/fbdev/riva/fbdev.c:1233: warning: Excess function parameter 'con' description in 'rivafb_pan_display'
   drivers/tty/vt/vt.c:1187: warning: Excess function parameter 'real_tty' description in 'vc_do_resize'
   drivers/tty/vt/vt.c:3902: warning: Function parameter or member 'vc' not described in 'con_debug_enter'
   drivers/tty/vt/vt.c:3902: warning: Excess function parameter 'sw' description in 'con_debug_enter'
   drivers/tty/vt/vt.c:3959: warning: Excess function parameter 'sw' description in 'con_debug_leave'
   drivers/dma/iop-adma.c:418: warning: Function parameter or member 'chan' not described in 'iop_adma_alloc_chan_resources'
>> drivers/clk/clk-versaclock5.c:792:6: warning: variable 'np_output' is used uninitialized whenever 'if' condition is true
   if (!child_name) {
   ^~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:818:14: note: uninitialized use occurs here
   of_node_put(np_output);
   ^~~~~~~~~
   drivers/clk/clk-versaclock5.c:792:2: note: remove the 'if' if its condition is always false
   if (!child_name) {
   ^~~~~~~~~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:787:31: note: initialize the variable 'np_output' to silence this warning
   struct device_node
   ^
   = NULL
   drivers/regulator/da9063-regulator.c:515:14: warning: initializer overrides prior initialization of this subobject
   .suspend = BFIELD(DA9063_REG_LDO9_CONT, DA9063_VLDO9_SEL),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/da9063-regulator.c:27:2: note: expanded from macro 'BFIELD'
   REG_FIELD(_reg, __builtin_ffs((int)_mask) - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/regmap.h:1124:37: note: expanded from macro 'REG_FIELD'
   #define REG_FIELD(_reg, _lsb, _msb) { ^~~~~~~~~~~~~
   drivers/regulator/da9063-regulator.c:514:3: note: previous initialization is here
   DA9063_LDO(DA9063, LDO9, 950, 50, 3600),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/da9063-regulator.c:103:13: note: expanded from macro 'DA9063_LDO'
   .suspend = BFIELD(DA9063_REG_##regl_name##_CONT, DA9063_LDO_CONF), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/regulator/da9063-regulator.c:27:2: note: expanded from macro 'BFIELD'
   REG_FIELD(_reg, __builtin_ffs((int)_mask) - 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/regmap.h:1124:37: note: expanded from macro 'REG_FIELD'
   #define REG_FIELD(_reg, _lsb, _msb) { ^~~~~~~~~~~~~
   1 warning generated.
   drivers/base/core.c:490: warning: Function parameter or member 'need_for_probe' not described in 'device_link_wait_for_supplier'
   1 warning generated.
   drivers/tty/serdev/core.c:811: warning: Function parameter or member 'owner' not described in '__serdev_device_driver_register'
   drivers/phy/ti/phy-j721e-wiz.c:829:14: warning: cast to smaller integer type 'enum wiz_type' from 'const void
   wiz->type = (enum wiz_type)of_device_get_match_data(dev);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/soc/qcom/llcc-qcom.c:74: warning: cannot understand function prototype: 'struct llcc_slice_config '
   1 warning generated.
   drivers/tty/serial/8250/8250_pci.c:2754:19: warning: unused function 'get_pci_irq'
   static inline int get_pci_irq(struct pci_dev
   ^
   drivers/char/agp/backend.c:68: warning: Function parameter or member 'pdev' not described in 'agp_backend_acquire'
   drivers/char/agp/backend.c:93: warning: Function parameter or member 'bridge' not described in 'agp_backend_release'
   drivers/soc/qcom/rpmhpd.c:52: warning: Function parameter or member 'parent' not described in 'rpmhpd'
   drivers/soc/qcom/rpmhpd.c:52: warning: Function parameter or member 'corner' not described in 'rpmhpd'
   drivers/soc/qcom/rpmhpd.c:52: warning: Function parameter or member 'active_corner' not described in 'rpmhpd'
   1 warning generated.
   drivers/char/agp/frontend.c:46:20: warning: no previous prototype for function 'agp_find_mem_by_key'
   struct agp_memory key)
   ^
   drivers/char/agp/frontend.c:46:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   struct agp_memory key)
   ^
   static
   drivers/char/agp/frontend.c:161:5: warning: no previous prototype for function 'agp_create_segment'
   int agp_create_segment(struct agp_client struct agp_region
   ^
   drivers/char/agp/frontend.c:161:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int agp_create_segment(struct agp_client struct agp_region
   ^
   static
   drivers/char/agp/frontend.c:213:26: warning: no previous prototype for function 'agp_find_private'
   struct agp_file_private pid)
   ^
   drivers/char/agp/frontend.c:213:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   struct agp_file_private pid)
   ^
   static
   drivers/char/agp/frontend.c:268:6: warning: no previous prototype for function 'agp_free_memory_wrap'
   void agp_free_memory_wrap(struct agp_memory
   ^
   drivers/char/agp/frontend.c:268:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void agp_free_memory_wrap(struct agp_memory
   ^
   static
   drivers/char/agp/frontend.c:274:20: warning: no previous prototype for function 'agp_allocate_memory_wrap'
   struct agp_memory pg_count, u32 type)
   ^
   drivers/char/agp/frontend.c:274:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   struct agp_memory pg_count, u32 type)
   ^
   static
   drivers/char/agp/frontend.c:486:20: warning: no previous prototype for function 'agp_find_client_by_pid'
   struct agp_client id)
   ^
   drivers/char/agp/frontend.c:486:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   struct agp_client id)
   ^
   static
   drivers/char/agp/frontend.c:511:20: warning: no previous prototype for function 'agp_create_client'
   struct agp_client id)
   ^
   drivers/char/agp/frontend.c:511:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   struct agp_client id)
   ^
   static
   drivers/char/agp/frontend.c:524:5: warning: no previous prototype for function 'agp_remove_client'
   int agp_remove_client(pid_t id)
   ^
   drivers/char/agp/frontend.c:524:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int agp_remove_client(pid_t id)
--
   drivers/clk/clk-fixed-factor.c:211: warning: Function parameter or member 'node' not described in 'of_fixed_factor_clk_setup'
   drivers/clk/clk-fixed-rate.c:173: warning: Function parameter or member 'node' not described in 'of_fixed_clk_setup'
   drivers/clk/clk.c:4145: warning: Function parameter or member 'dev' not described in 'devm_clk_unregister'
   drivers/clk/clk.c:4336: warning: Function parameter or member 'get_hw' not described in 'of_clk_provider'
   drivers/clk/clk-fixed-mmio.c:62: warning: Function parameter or member 'pdev' not described in 'of_fixed_mmio_clk_probe'
>> drivers/clk/clk-versaclock5.c:792:6: warning: variable 'np_output' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!child_name) {
               ^~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:818:14: note: uninitialized use occurs here
           of_node_put(np_output);
                       ^~~~~~~~~
   drivers/clk/clk-versaclock5.c:792:2: note: remove the 'if' if its condition is always false
           if (!child_name) {
           ^~~~~~~~~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:787:31: note: initialize the variable 'np_output' to silence this warning
           struct device_node *np_output;
                                        ^
                                         = NULL
   1 warning generated.
   drivers/clk/clk-xgene.c:229: warning: Function parameter or member 'mask' not described in 'xgene_clk_pmd'
   drivers/clk/clk-xgene.c:229: warning: Function parameter or member 'flags' not described in 'xgene_clk_pmd'
   drivers/clk/bcm/clk-iproc-pll.c:712: warning: Function parameter or member 'pll' not described in 'iproc_pll_sw_cfg'
   drivers/clk/qcom/clk-regmap.c:97: warning: Function parameter or member 'dev' not described in 'devm_clk_register_regmap'
   drivers/clk/samsung/clk-s3c2410.c:320:13: warning: no previous prototype for function 's3c2410_common_clk_init' [-Wmissing-prototypes]
   void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
               ^
   drivers/clk/samsung/clk-s3c2410.c:320:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f,
   ^
   static 
   1 warning generated.
   drivers/clk/samsung/clk-s3c2412.c:205:13: warning: no previous prototype for function 's3c2412_common_clk_init' [-Wmissing-prototypes]
   void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
               ^
   drivers/clk/samsung/clk-s3c2412.c:205:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2412_common_clk_init(struct device_node *np, unsigned long xti_f,
   ^
   static 
   1 warning generated.
   drivers/clk/samsung/clk-s3c2443.c:341:13: warning: no previous prototype for function 's3c2443_common_clk_init' [-Wmissing-prototypes]
   void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
               ^
   drivers/clk/samsung/clk-s3c2443.c:341:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init s3c2443_common_clk_init(struct device_node *np, unsigned long xti_f,
   ^
   static 
   1 warning generated.
   drivers/clk/qcom/gcc-msm8939.c:598:32: warning: unused variable 'gcc_xo_gpll6_gpll0_map' [-Wunused-const-variable]
   static const struct parent_map gcc_xo_gpll6_gpll0_map[] = {
                                  ^
   drivers/clk/qcom/gcc-msm8939.c:610:32: warning: unused variable 'gcc_xo_gpll6_gpll0a_map' [-Wunused-const-variable]
   static const struct parent_map gcc_xo_gpll6_gpll0a_map[] = {
                                  ^
   2 warnings generated.
   drivers/clk/sifive/fu540-prci.c:520: warning: Function parameter or member 'pd' not described in '__prci_register_clocks'
   drivers/clk/renesas/renesas-cpg-mssr.c:125: warning: cannot understand function prototype: 'struct cpg_mssr_priv '
   drivers/clk/qcom/mmcc-msm8974.c:77:32: warning: unused variable 'mmcc_xo_mmpll0_1_2_gpll0_map' [-Wunused-const-variable]
   static const struct parent_map mmcc_xo_mmpll0_1_2_gpll0_map[] = {
                                  ^
   drivers/clk/qcom/mmcc-msm8974.c:85:27: warning: unused variable 'mmcc_xo_mmpll0_1_2_gpll0' [-Wunused-const-variable]
   static const char * const mmcc_xo_mmpll0_1_2_gpll0[] = {
                             ^
   2 warnings generated.
   drivers/clk/versatile/clk-icst.c:53: warning: Function parameter or member 'map' not described in 'clk_icst'
   drivers/clk/versatile/clk-icst.c:53: warning: Function parameter or member 'vcoreg_off' not described in 'clk_icst'
   drivers/clk/versatile/clk-icst.c:53: warning: Function parameter or member 'lockreg_off' not described in 'clk_icst'
   drivers/clk/versatile/clk-icst.c:435: warning: cannot understand function prototype: 'const struct icst_params icst525_apcp_cm_params = '
   drivers/clk/qcom/gcc-sdm660.c:52:32: warning: unused variable 'gcc_parent_map_xo_gpll0' [-Wunused-const-variable]
   static const struct parent_map gcc_parent_map_xo_gpll0[] = {
                                  ^
   1 warning generated.
--
>> drivers/clk/clk-versaclock5.c:792:6: warning: variable 'np_output' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
           if (!child_name) {
               ^~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:818:14: note: uninitialized use occurs here
           of_node_put(np_output);
                       ^~~~~~~~~
   drivers/clk/clk-versaclock5.c:792:2: note: remove the 'if' if its condition is always false
           if (!child_name) {
           ^~~~~~~~~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:787:31: note: initialize the variable 'np_output' to silence this warning
           struct device_node *np_output;
                                        ^
                                         = NULL
   1 warning generated.
--
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:110:6: warning: no previous prototype for function 'dce6_afmt_select_pin'
   void dce6_afmt_select_pin(struct drm_encoder
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:110:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_afmt_select_pin(struct drm_encoder
   ^
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:123:6: warning: no previous prototype for function 'dce6_afmt_write_latency_fields'
   void dce6_afmt_write_latency_fields(struct drm_encoder
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:123:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_afmt_write_latency_fields(struct drm_encoder
   ^
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:152:6: warning: no previous prototype for function 'dce6_afmt_hdmi_write_speaker_allocation'
   void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:152:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_afmt_hdmi_write_speaker_allocation(struct drm_encoder
   ^
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:177:6: warning: no previous prototype for function 'dce6_afmt_dp_write_speaker_allocation'
   void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:177:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_afmt_dp_write_speaker_allocation(struct drm_encoder
   ^
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:202:6: warning: no previous prototype for function 'dce6_afmt_write_sad_regs'
   void dce6_afmt_write_sad_regs(struct drm_encoder
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:202:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_afmt_write_sad_regs(struct drm_encoder
   ^
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:268:6: warning: no previous prototype for function 'dce6_hdmi_audio_set_dto'
   void dce6_hdmi_audio_set_dto(struct radeon_device
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:268:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_hdmi_audio_set_dto(struct radeon_device
   ^
   static
   drivers/gpu/drm/radeon/dce6_afmt.c:287:6: warning: no previous prototype for function 'dce6_dp_audio_set_dto'
   void dce6_dp_audio_set_dto(struct radeon_device
   ^
   drivers/gpu/drm/radeon/dce6_afmt.c:287:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dce6_dp_audio_set_dto(struct radeon_device
   ^
   static
   9 warnings generated.
   drivers/gpu/drm/vmwgfx/vmwgfx_bo.c:142: warning: Excess function parameter 'pin' description in 'vmw_bo_pin_in_vram_or_gmr'
   drivers/gpu/drm/vmwgfx/vmwgfx_bo.c:601: warning: Function parameter or member 'p_base' not described in 'vmw_user_bo_alloc'
   drivers/usb/typec/altmodes/displayport.c:511:5: warning: no previous prototype for function 'dp_altmode_probe'
   int dp_altmode_probe(struct typec_altmode
   ^
   drivers/usb/typec/altmodes/displayport.c:511:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int dp_altmode_probe(struct typec_altmode
   ^
   static
   drivers/usb/typec/altmodes/displayport.c:551:6: warning: no previous prototype for function 'dp_altmode_remove'
   void dp_altmode_remove(struct typec_altmode
   ^
   drivers/usb/typec/altmodes/displayport.c:551:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void dp_altmode_remove(struct typec_altmode
   ^
   static
   2 warnings generated.
   drivers/usb/typec/altmodes/displayport.c:18: warning: Function parameter or member '_dp' not described in 'DP_HEADER'
   drivers/usb/typec/altmodes/displayport.c:18: warning: Function parameter or member 'cmd' not described in 'DP_HEADER'
   drivers/usb/typec/tcpm/tcpm.c:1551:39: warning: unused variable 'tcpm_altmode_ops'
   static const struct typec_altmode_ops tcpm_altmode_ops = {
   ^
   drivers/regulator/lp872x.c:876:5: warning: cast to smaller integer type 'enum lp872x_regulator_id' from 'void
   (enum
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.
   drivers/gpu/drm/radeon/radeon_vm.c:131: warning: Function parameter or member 'rdev' not described in 'radeon_vm_get_bos'
   drivers/gpu/drm/radeon/radeon_vm.c:643: warning: Excess function parameter 'start' description in 'radeon_vm_update_page_directory'
   drivers/gpu/drm/radeon/radeon_vm.c:643: warning: Excess function parameter 'end' description in 'radeon_vm_update_page_directory'
   drivers/gpu/drm/radeon/radeon_vm.c:819: warning: Function parameter or member 'ib' not described in 'radeon_vm_update_ptes'
   drivers/gpu/drm/radeon/radeon_vm.c:915: warning: Function parameter or member 'bo_va' not described in 'radeon_vm_bo_update'
   drivers/gpu/drm/radeon/radeon_vm.c:915: warning: Excess function parameter 'vm' description in 'radeon_vm_bo_update'
   drivers/gpu/drm/radeon/radeon_vm.c:915: warning: Excess function parameter 'bo' description in 'radeon_vm_bo_update'
   drivers/gpu/drm/radeon/radeon_vm.c:1155: warning: Excess function parameter 'vm' description in 'radeon_vm_bo_invalidate'
   drivers/base/platform.c:1352:20: warning: no previous prototype for function 'early_platform_cleanup'
   void __weak __init early_platform_cleanup(void) { }
   ^
   drivers/base/platform.c:1352:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __weak __init early_platform_cleanup(void) { }
   ^
   static
   drivers/base/cpu.c:565:16: warning: no previous prototype for function 'cpu_show_srbds'
   ssize_t __weak cpu_show_srbds(struct device
   ^
   drivers/base/cpu.c:565:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   ssize_t __weak cpu_show_srbds(struct device
   ^
   static
   1 warning generated.
>> drivers/clk/clk-versaclock5.c:792:6: warning: variable 'np_output' is used uninitialized whenever 'if' condition is true
   if (!child_name) {
   ^~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:818:14: note: uninitialized use occurs here
   of_node_put(np_output);
   ^~~~~~~~~
   drivers/clk/clk-versaclock5.c:792:2: note: remove the 'if' if its condition is always false
   if (!child_name) {
   ^~~~~~~~~~~~~~~~~~
   drivers/clk/clk-versaclock5.c:787:31: note: initialize the variable 'np_output' to silence this warning
   struct device_node
   ^
   = NULL
   drivers/dma/mediatek/mtk-hsdma.c:120: warning: Function parameter or member 'desc1' not described in 'mtk_hsdma_pdesc'
   drivers/dma/mediatek/mtk-hsdma.c:120: warning: Function parameter or member 'desc2' not described in 'mtk_hsdma_pdesc'
   drivers/dma/mediatek/mtk-hsdma.c:120: warning: Function parameter or member 'desc3' not described in 'mtk_hsdma_pdesc'
   drivers/dma/mediatek/mtk-hsdma.c:120: warning: Function parameter or member 'desc4' not described in 'mtk_hsdma_pdesc'
   drivers/usb/typec/ucsi/ucsi.c:1005:5: warning: no previous prototype for function 'ucsi_init'
   int ucsi_init(struct ucsi
   ^
   drivers/usb/typec/ucsi/ucsi.c:1005:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int ucsi_init(struct ucsi
   ^
   static
   1 warning generated.
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:90: warning: cannot understand function prototype: 'struct vmw_screen_object_unit '
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:122: warning: Function parameter or member 'dev_priv' not described in 'vmw_sou_fifo_create'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:122: warning: Function parameter or member 'sou' not described in 'vmw_sou_fifo_create'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:122: warning: Function parameter or member 'x' not described in 'vmw_sou_fifo_create'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:122: warning: Function parameter or member 'y' not described in 'vmw_sou_fifo_create'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:122: warning: Function parameter or member 'mode' not described in 'vmw_sou_fifo_create'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:168: warning: Function parameter or member 'dev_priv' not described in 'vmw_sou_fifo_destroy'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:168: warning: Function parameter or member 'sou' not described in 'vmw_sou_fifo_destroy'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:283: warning: Function parameter or member 'old_state' not described in 'vmw_sou_crtc_atomic_enable'
   drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c:293: warning: Function parameter or member 'old_state' not described in 'vmw_sou_crtc_atomic_disable'
   1 warning generated.
   1 warning generated.
   drivers/usb/host/fotg210-hcd.c:5569: warning: Function parameter or member 'pdev' not described in 'fotg210_hcd_probe'
   drivers/usb/host/fotg210-hcd.c:5666: warning: Function parameter or member 'pdev' not described in 'fotg210_hcd_remove'
   drivers/usb/host/fotg210-hcd.c:5666: warning: Excess function parameter 'dev' description in 'fotg210_hcd_remove'
   drivers/dma/ti/edma.c:363:20: warning: unused function 'edma_or_array'
   static inline void edma_or_array(struct edma_cc int offset, int i,
   ^
   drivers/dma/ti/edma.c:381:28: warning: unused function 'edma_shadow0_read'
   static inline unsigned int edma_shadow0_read(struct edma_cc int offset)
   ^
   drivers/dma/ti/edma.c:404:28: warning: unused function 'edma_param_read'
   static inline unsigned int edma_param_read(struct edma_cc int offset,
   ^
   drivers/dma/ti/edma.c:410:20: warning: unused function 'edma_param_write'
   static inline void edma_param_write(struct edma_cc int offset,
   ^
   drivers/dma/ti/edma.c:422:20: warning: unused function 'edma_param_and'
   static inline void edma_param_and(struct edma_cc int offset, int param_no,
   ^
   drivers/dma/ti/edma.c:428:20: warning: unused function 'edma_param_or'
   static inline void edma_param_or(struct edma_cc int offset, int param_no,
   ^
   drivers/dma/ti/edma.c:754:31: warning: unused function 'to_edma_cc'
   static inline struct edma_cc dma_device
   ^
   drivers/iommu/intel/pasid.c:10: warning: Function parameter or member 'fmt' not described in 'pr_fmt'
   drivers/video/fbdev/hgafb.c:365: warning: Function parameter or member 'init' not described in 'hgafb_open'
   drivers/video/fbdev/hgafb.c:365: warning: Excess function parameter 'int' description in 'hgafb_open'
   drivers/video/fbdev/hgafb.c:379: warning: Function parameter or member 'init' not described in 'hgafb_release'
   drivers/video/fbdev/hgafb.c:379: warning: Excess function parameter 'int' description in 'hgafb_release'
   1 warning generated.
   7 warnings generated.
   drivers/gpu/drm/vmwgfx/vmwgfx_context.c:121: warning: Function parameter or member 'dev_priv' not described in 'vmw_context_cotables_unref'
   drivers/gpu/drm/vmwgfx/vmwgfx_context.c:121: warning: Function parameter or member 'uctx' not described in 'vmw_context_cotables_unref'
   drivers/gpu/drm/vmwgfx/vmwgfx_context.c:681: warning: Function parameter or member 'base' not described in 'vmw_user_context_base_to_res'
   drivers/gpu/drm/vmwgfx/vmwgfx_context.c:707: warning: Function parameter or member 'p_base' not described in 'vmw_user_context_base_release'
   drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c:226: warning: Function parameter or member 'control' not described in 'smu_v11_0_i2c_transmit'
   drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c:326: warning: Function parameter or member 'control' not described in 'smu_v11_0_i2c_receive'
   drivers/gpu/drm/amd/amdgpu/smu_v11_0_i2c.c:326: warning: Function parameter or member 'data' not described in 'smu_v11_0_i2c_receive'
   drivers/gpu/drm/radeon/radeon_ib.c:61: warning: Function parameter or member 'vm' not described in 'radeon_ib_get'
   drivers/tty/serial/8250/8250_pci.c:2754:19: warning: unused function 'get_pci_irq'
   static inline int get_pci_irq(struct pci_dev
   ^
   drivers/clk/clk-xgene.c:229: warning: Function parameter or member 'mask' not described in 'xgene_clk_pmd'
   drivers/clk/clk-xgene.c:229: warning: Function parameter or member 'flags' not described in 'xgene_clk_pmd'
   1 warning generated.
   drivers/usb/chipidea/ci_hdrc_pci.c:132: warning: cannot understand function prototype: 'const struct pci_device_id = '
   arch/x86/kernel/apic/apic.c:2126: warning: Function parameter or member 'spurious_interrupt' not described in 'DEFINE_IDTENTRY_IRQ'
   arch/x86/kernel/apic/apic.c:2126: warning: Excess function parameter 'regs' description in 'DEFINE_IDTENTRY_IRQ'
   arch/x86/kernel/apic/apic.c:2126: warning: Excess function parameter 'vector' description in 'DEFINE_IDTENTRY_IRQ'
   drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:34:6: warning: no previous prototype for function 'is_fru_eeprom_supported'
   bool is_fru_eeprom_supported(struct amdgpu_device
   ^
   drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:34:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool is_fru_eeprom_supported(struct amdgpu_device
   ^
   static
   drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:50:5: warning: no previous prototype for function 'amdgpu_fru_read_eeprom'
   int amdgpu_fru_read_eeprom(struct amdgpu_device uint32_t addrptr,
   ^
   drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:50:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int amdgpu_fru_read_eeprom(struct amdgpu_device uint32_t addrptr,
   ^
   static
   drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c:87:5: warning: no previous prototype for function 'amdgpu_fru_get_product_info'
..

vim +792 drivers/clk/clk-versaclock5.c

   783	
   784	static int vc5_get_output_config(struct i2c_client *client,
   785					 struct vc5_hw_data *clk_out)
   786	{
   787		struct device_node *np_output;
   788		char *child_name;
   789		int ret = 0;
   790	
   791		child_name = kasprintf(GFP_KERNEL, "OUT%d", clk_out->num + 1);
 > 792		if (!child_name) {
   793			ret = -ENOMEM;
   794			goto output_error;
   795		}
   796		np_output = of_get_child_by_name(client->dev.of_node, child_name);
   797		kfree(child_name);
   798		if (!np_output)
   799			return 0;
   800	
   801		ret = vc5_update_mode(np_output, clk_out);
   802		if (ret)
   803			goto output_error;
   804	
   805		ret = vc5_update_power(np_output, clk_out);
   806		if (ret)
   807			goto output_error;
   808	
   809		ret = vc5_update_slew(np_output, clk_out);
   810	
   811	output_error:
   812		if (ret) {
   813			dev_err(&client->dev,
   814				"Invalid clock output configuration OUT%d\n",
   815				clk_out->num + 1);
   816		}
   817	
   818		of_node_put(np_output);
   819	
   820		return ret;
   821	}
   822	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 75368 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] clk: vc5: Add memory check to prevent oops
  2020-06-30 21:01 [PATCH] clk: vc5: Add memory check to prevent oops Adam Ford
  2020-07-01 11:06 ` kernel test robot
@ 2020-07-02 14:42 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2020-07-02 14:42 UTC (permalink / raw)
  To: kbuild, Adam Ford, linux-clk
  Cc: lkp, kbuild-all, dan.carpenter, aford, Adam Ford, Marek Vasut,
	Michael Turquette, Stephen Boyd, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3796 bytes --]

Hi Adam,

Thank you for the patch! Perhaps something to improve:

url:    https://github.com/0day-ci/linux/commits/Adam-Ford/clk-vc5-Add-memory-check-to-prevent-oops/20200701-050451
base:   https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git clk-next
config: i386-randconfig-m021-20200701 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/clk/clk-versaclock5.c:818 vc5_get_output_config() error: uninitialized symbol 'np_output'.

# https://github.com/0day-ci/linux/commit/d445df5e4f918f08f66e20c366dc6c81dcdc8b57
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout d445df5e4f918f08f66e20c366dc6c81dcdc8b57
vim +/np_output +818 drivers/clk/clk-versaclock5.c

260249f929e81d Adam Ford 2020-06-03  783  
260249f929e81d Adam Ford 2020-06-03  784  static int vc5_get_output_config(struct i2c_client *client,
260249f929e81d Adam Ford 2020-06-03  785  				 struct vc5_hw_data *clk_out)
260249f929e81d Adam Ford 2020-06-03  786  {
260249f929e81d Adam Ford 2020-06-03  787  	struct device_node *np_output;
                                                                    ^^^^^^^^^

260249f929e81d Adam Ford 2020-06-03  788  	char *child_name;
260249f929e81d Adam Ford 2020-06-03  789  	int ret = 0;
260249f929e81d Adam Ford 2020-06-03  790  
260249f929e81d Adam Ford 2020-06-03  791  	child_name = kasprintf(GFP_KERNEL, "OUT%d", clk_out->num + 1);
d445df5e4f918f Adam Ford 2020-06-30  792  	if (!child_name) {
d445df5e4f918f Adam Ford 2020-06-30  793  		ret = -ENOMEM;
d445df5e4f918f Adam Ford 2020-06-30  794  		goto output_error;
                                                        ^^^^^^^^^^^^^^^^^^
Better to just return directly, because there is no clean up.

d445df5e4f918f Adam Ford 2020-06-30  795  	}
260249f929e81d Adam Ford 2020-06-03  796  	np_output = of_get_child_by_name(client->dev.of_node, child_name);
260249f929e81d Adam Ford 2020-06-03  797  	kfree(child_name);
260249f929e81d Adam Ford 2020-06-03  798  	if (!np_output)
d445df5e4f918f Adam Ford 2020-06-30  799  		return 0;
260249f929e81d Adam Ford 2020-06-03  800  
260249f929e81d Adam Ford 2020-06-03  801  	ret = vc5_update_mode(np_output, clk_out);
260249f929e81d Adam Ford 2020-06-03  802  	if (ret)
260249f929e81d Adam Ford 2020-06-03  803  		goto output_error;
260249f929e81d Adam Ford 2020-06-03  804  
260249f929e81d Adam Ford 2020-06-03  805  	ret = vc5_update_power(np_output, clk_out);
260249f929e81d Adam Ford 2020-06-03  806  	if (ret)
260249f929e81d Adam Ford 2020-06-03  807  		goto output_error;
260249f929e81d Adam Ford 2020-06-03  808  
260249f929e81d Adam Ford 2020-06-03  809  	ret = vc5_update_slew(np_output, clk_out);
260249f929e81d Adam Ford 2020-06-03  810  
260249f929e81d Adam Ford 2020-06-03  811  output_error:
260249f929e81d Adam Ford 2020-06-03  812  	if (ret) {
260249f929e81d Adam Ford 2020-06-03  813  		dev_err(&client->dev,
260249f929e81d Adam Ford 2020-06-03  814  			"Invalid clock output configuration OUT%d\n",
260249f929e81d Adam Ford 2020-06-03  815  			clk_out->num + 1);
260249f929e81d Adam Ford 2020-06-03  816  	}
260249f929e81d Adam Ford 2020-06-03  817  
260249f929e81d Adam Ford 2020-06-03 @818  	of_node_put(np_output);
                                                            ^^^^^^^^^
Uninitialized.

260249f929e81d Adam Ford 2020-06-03  819  
260249f929e81d Adam Ford 2020-06-03  820  	return ret;
260249f929e81d Adam Ford 2020-06-03  821  }
260249f929e81d Adam Ford 2020-06-03  822  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 41839 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-07-02 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-30 21:01 [PATCH] clk: vc5: Add memory check to prevent oops Adam Ford
2020-07-01 11:06 ` kernel test robot
2020-07-02 14:42 ` 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).