Skip to contentSkip to conversation

drivers/net/wireless/ath/wil6210/debugfs.c:1030:9: warning: variable 'rc' is uninitialized when used here

PATCH In review kernel test robot 4 participants 4 messages Jul 24, 2022 – Jul 27, 2022

Subsystems (3)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://github.com/ammarfaizi2/linux-block kvalo/ath/pending
head:   086f67ba21ede199307e78476353bda9ffef982c
commit: 7a4836560a6198d245d5732e26f94898b12eb760 [3/9] wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()
config: powerpc-randconfig-r002-20220718 (https://download.01.org/0day-ci/archive/20220725/[email protected]/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project d74b88c69dc2644bd0dc5d64e2d7413a0d4040e5)

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 powerpc cross compiling tool for clang build
# apt-get install binutils-powerpc-linux-gnu
# https://github.com/ammarfaizi2/linux-block/commit/7a4836560a6198d245d5732e26f94898b12eb760
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block kvalo/ath/pending
git checkout 7a4836560a6198d245d5732e26f94898b12eb760
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/net/wireless/ath/wil6210/

If you fix the issue, kindly add following tag where applicable

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/ath/wil6210/debugfs.c:1030:9: warning: variable 'rc' is uninitialized when used here [-Wuninitialized]
           return rc;
                  ^~
   drivers/net/wireless/ath/wil6210/debugfs.c:1013:8: note: initialize the variable 'rc' to silence this warning
           int rc, rc1;
                 ^
                  = 0

1 warning generated.

vim +/rc +1030 drivers/net/wireless/ath/wil6210/debugfs.c

2be7d22f062535 Vladimir Kondratiev 2012-12-20  1000  
ff974e40833413 Vladimir Kondratiev 2014-06-16  1001  /* Write WMI command (w/o mbox header) to this file to send it
ff974e40833413 Vladimir Kondratiev 2014-06-16  1002   * WMI starts from wil6210_mbox_hdr_wmi header
ff974e40833413 Vladimir Kondratiev 2014-06-16  1003   */
ff974e40833413 Vladimir Kondratiev 2014-06-16  1004  static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
ff974e40833413 Vladimir Kondratiev 2014-06-16  1005  				  size_t len, loff_t *ppos)
ff974e40833413 Vladimir Kondratiev 2014-06-16  1006  {
ff974e40833413 Vladimir Kondratiev 2014-06-16  1007  	struct wil6210_priv *wil = file->private_data;
e00243fab84b4e Lior David          2018-02-26  1008  	struct wil6210_vif *vif = ndev_to_vif(wil->main_ndev);
b874ddecae0a08 Lior David          2016-03-01  1009  	struct wmi_cmd_hdr *wmi;
ff974e40833413 Vladimir Kondratiev 2014-06-16  1010  	void *cmd;
b874ddecae0a08 Lior David          2016-03-01  1011  	int cmdlen = len - sizeof(struct wmi_cmd_hdr);
ff974e40833413 Vladimir Kondratiev 2014-06-16  1012  	u16 cmdid;
ff974e40833413 Vladimir Kondratiev 2014-06-16  1013  	int rc, rc1;
ff974e40833413 Vladimir Kondratiev 2014-06-16  1014  
7a4836560a6198 Dan Carpenter       2022-07-15  1015  	if (cmdlen < 0 || *ppos != 0)
ff974e40833413 Vladimir Kondratiev 2014-06-16  1016  		return -EINVAL;
ff974e40833413 Vladimir Kondratiev 2014-06-16  1017  
7a4836560a6198 Dan Carpenter       2022-07-15  1018  	wmi = memdup_user(buf, len);
7a4836560a6198 Dan Carpenter       2022-07-15  1019  	if (IS_ERR(wmi))
7a4836560a6198 Dan Carpenter       2022-07-15  1020  		return PTR_ERR(wmi);
ff974e40833413 Vladimir Kondratiev 2014-06-16  1021  
69218a48005d0c Lior David          2016-03-21  1022  	cmd = (cmdlen > 0) ? &wmi[1] : NULL;
b874ddecae0a08 Lior David          2016-03-01  1023  	cmdid = le16_to_cpu(wmi->command_id);
ff974e40833413 Vladimir Kondratiev 2014-06-16  1024  
e00243fab84b4e Lior David          2018-02-26  1025  	rc1 = wmi_send(wil, cmdid, vif->mid, cmd, cmdlen);
ff974e40833413 Vladimir Kondratiev 2014-06-16  1026  	kfree(wmi);
ff974e40833413 Vladimir Kondratiev 2014-06-16  1027  
af3db60a30331d Lazar Alexei        2017-01-20  1028  	wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1);
ff974e40833413 Vladimir Kondratiev 2014-06-16  1029  

ff974e40833413 Vladimir Kondratiev 2014-06-16 @1030 return rc;
ff974e40833413 Vladimir Kondratiev 2014-06-16 1031 } ff974e40833413 Vladimir Kondratiev 2014-06-16 1032

:::::: The code at line 1030 was first introduced by commit
:::::: ff974e4083341383d3dd4079e52ed30f57f376f0 wil6210: debugfs interface to send raw WMI command

:::::: TO: Vladimir Kondratiev <[email protected]> :::::: CC: John W. Linville <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://01.org/lkp
#1 lore raw

PATCH 1/1 wifi: wil6210: debugfs: fix uninitialized variable use in `wil_write_file_wmi()`

Commit 7a4836560a61 changes simple_write_to_buffer() with memdup_user() but it forgets to change the value to be returned that came from simple_write_to_buffer() call. It results in the following warning:

warning: variable 'rc' is uninitialized when used here [-Wuninitialized]

           return rc;
                  ^~

Remove rc variable and just return the passed in length if the memdup_user() succeeds.

Cc Dan Carpenter <[email protected]>
Fixes 7a4836560a6198d245d5732e26f94898b12eb760 ("wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()")
Fixes ff974e4083341383d3dd4079e52ed30f57f376f0 ("wil6210: debugfs interface to send raw WMI command")
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/wil6210/debugfs.c +2 -2
index fe84362718de..04d1aa0e2d35 100644
@@ -1010,7 +1010,7 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 	void *cmd;
 	int cmdlen = len - sizeof(struct wmi_cmd_hdr);
 	u16 cmdid;
-	int rc, rc1;
+	int rc1;
 
 	if (cmdlen < 0 || *ppos != 0)
 		return -EINVAL;
@@ -1027,7 +1027,7 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf,
 
 	wil_info(wil, "0x%04x[%d] -> %d\n", cmdid, cmdlen, rc1);
 
-	return rc;
+	return len;
 }
 
 static const struct file_operations fops_wmi = {

base-commit: 086f67ba21ede199307e78476353bda9ffef982c

Signature · 1 line
Ammar Faizi
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] wifi: wil6210: debugfs: fix uninitialized variable use in `wil_write_file_wmi()`

Quoted 8 lines · Ammar Faizi

Commit 7a4836560a61 changes simple_write_to_buffer() with memdup_user() but it forgets to change the value to be returned that came from simple_write_to_buffer() call. It results in the following warning:

warning: variable 'rc' is uninitialized when used here [-Wuninitialized]

           return rc;
                  ^~
Quoted 8 lines

Remove rc variable and just return the passed in length if the memdup_user() succeeds.

Cc Dan Carpenter <[email protected]>
Fixes 7a4836560a6198d245d5732e26f94898b12eb760 ("wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()")
Fixes ff974e4083341383d3dd4079e52ed30f57f376f0 ("wil6210: debugfs interface to send raw WMI command")

Oops. Sorry!

regards,
dan carpenter

#3 lore raw

Re: [PATCH] wifi: wil6210: debugfs: fix uninitialized variable use in `wil_write_file_wmi()`

In reply to Ammar Faizi
Quoted 11 lines · Ammar Faizi

Commit 7a4836560a61 changes simple_write_to_buffer() with memdup_user() but it forgets to change the value to be returned that came from simple_write_to_buffer() call. It results in the following warning:

warning: variable 'rc' is uninitialized when used here [-Wuninitialized]

           return rc;
                  ^~

Remove rc variable and just return the passed in length if the memdup_user() succeeds.

Quoted 7 lines
Cc Dan Carpenter <[email protected]>
Fixes 7a4836560a6198d245d5732e26f94898b12eb760 ("wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi()")
Fixes ff974e4083341383d3dd4079e52ed30f57f376f0 ("wil6210: debugfs interface to send raw WMI command")

Patch applied to ath-next branch of ath.git, thanks.

d578e0af3a00 wifi: wil6210: debugfs: fix uninitialized variable use in wil_write_file_wmi()

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/20220724202452.61846-1-ammar.faizi(a)intel.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches