misc: rtsx: Fix clang -Wsometimes-uninitialized in rts5261_init_from_hw()
PATCH 1/1 misc: rtsx: Fix clang -Wsometimes-uninitialized in rts5261_init_from_hw()
Clang warns:
drivers/misc/cardreader/rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
} else if (efuse_valid == 0) {
^~~~~~~~~~~~~~~~
drivers/misc/cardreader/rts5261.c:412:30: note: uninitialized use occurs here
pci_read_config_dword(pdev, setting_reg2, &lval2);
^~~~~~~~~~~~efuse_valid == 1 is not a valid value so just return early from the function to avoid using setting_reg2 uninitialized.
---
This is basically a v2 of https://lore.kernel.org/[email protected]/.
drivers/misc/cardreader/rts5261.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/misc/cardreader/rts5261.c +2 -0
@@ -407,6 +407,8 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)// default setting_reg1 =PCR_SETTING_REG1 ; setting_reg2 =PCR_SETTING_REG2 ; + }else { +return ; }pci_read_config_dword (pdev, setting_reg2, &lval2);
base-commit: 90de6805267f8c79cd2b1a36805071e257c39b5c
Signature · 1 line
2.36.1
Quoted 13 lines · Nathan Chancellor
Clang warns:
drivers/misc/cardreader/rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]} else if (efuse_valid == 0) { ^~~~~~~~~~~~~~~~ drivers/misc/cardreader/rts5261.c:412:30: note: uninitialized use occurs here pci_read_config_dword(pdev, setting_reg2, &lval2); ^~~~~~~~~~~~
efuse_valid== 1 is not a valid value so just return early from the function to avoid usingsetting_reg2uninitialized.
Quoted 6 lines
Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")Reported-by Dan Carpenter <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Tom Rix <[email protected]>Suggested-by Ricky WU <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Looks good to me,
From: Nathan Chancellor <[email protected]>
Date: Mon, 23 May 2022 08:05:22 -0700
Quoted 12 lines
Clang warns:
drivers/misc/cardreader/rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]} else if (efuse_valid == 0) { ^~~~~~~~~~~~~~~~ drivers/misc/cardreader/rts5261.c:412:30: note: uninitialized use occurs here pci_read_config_dword(pdev, setting_reg2, &lval2); ^~~~~~~~~~~~
efuse_valid== 1 is not a valid value so just return early from the function to avoid usingsetting_reg2uninitialized.
Quoted 6 lines
Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")Reported-by Dan Carpenter <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Tom Rix <[email protected]>Suggested-by Ricky WU <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Ping? Mainline 5.19-rc1 is now broken due to this.
Quoted 21 lines
---
This is basically a v2 of https://lore.kernel.org/[email protected]/.
drivers/misc/cardreader/rts5261.c | 2 ++ 1 file changed, 2 insertions(+)drivers/misc/cardreader/rts5261.c +2
-0@@ -407,6 +407,8 @@ static void rts5261_init_from_hw(struct rtsx_pcr *pcr)// default setting_reg1 =PCR_SETTING_REG1 ; setting_reg2 =PCR_SETTING_REG2 ; + }else { +return ; }pci_read_config_dword (pdev, setting_reg2, &lval2);
Quoted 3 lines
base-commit:
90de6805267f8c79cd2b1a36805071e257c39b5cSignature · 1 line
2.36.1
Thanks,
Al
Greg Kroah-Hartman
maintainerQuoted 15 lines · Alexander Lobakin
From: Nathan Chancellor <[email protected]>
Date: Mon, 23 May 2022 08:05:22 -0700Quoted 12 lines
Clang warns:
drivers/misc/cardreader/rts5261.c:406:13: error: variable 'setting_reg2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]} else if (efuse_valid == 0) { ^~~~~~~~~~~~~~~~ drivers/misc/cardreader/rts5261.c:412:30: note: uninitialized use occurs here pci_read_config_dword(pdev, setting_reg2, &lval2); ^~~~~~~~~~~~
efuse_valid== 1 is not a valid value so just return early from the function to avoid usingsetting_reg2uninitialized.
Quoted 8 lines
Quoted 6 lines
Fixes b1c5f3085149 ("misc: rtsx: add rts5261 efuse function")Reported-by Dan Carpenter <[email protected]>Reported-by kernel test robot <[email protected]>Reported-by Tom Rix <[email protected]>Suggested-by Ricky WU <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>Ping? Mainline 5.19-rc1 is now broken due to this.
Perhaps use a different compiler? :)
It's in my "to apply" queue, will get there hopefully this week, it came in during the merge window which prevented me from touching it. You know this...
thanks,
greg k-h