Skip to content

Commit 8362bf8

Browse files
nathanchancedtor
authored andcommitted
Input: mcs-touchkey - fix uninitialized use of error in mcs_touchkey_probe()
Clang warns (or errors with CONFIG_WERROR=y): drivers/input/keyboard/mcs_touchkey.c:149:49: error: variable 'error' is uninitialized when used here [-Werror,-Wuninitialized] 149 | dev_err(&client->dev, "i2c read error[%d]\n", error); | ^~~~~ include/linux/dev_printk.h:144:65: note: expanded from macro 'dev_err' 144 | dev_printk_index_wrap(_dev_err, KERN_ERR, dev, dev_fmt(fmt), ##__VA_ARGS__) | ^~~~~~~~~~~ include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap' 110 | _p_func(dev, fmt, ##__VA_ARGS__); \ | ^~~~~~~~~~~ drivers/input/keyboard/mcs_touchkey.c:110:11: note: initialize the variable 'error' to silence this warning 110 | int error; | ^ | = 0 1 error generated. A refactoring updated the error handling in this block but did not update the dev_err() call to use fw_ver instead of error. Do so now to fix the warning and avoid printing uninitialized memory. Closes: ClangBuiltLinux/linux#1893 Fixes: e175eae ("Input: mcs-touchkey - convert to use devm_* api") Signed-off-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/20230725-mcs_touchkey-fix-wuninitialized-v1-1-615db39af51c@kernel.org Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 447c095 commit 8362bf8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/input/keyboard/mcs_touchkey.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static int mcs_touchkey_probe(struct i2c_client *client)
146146

147147
fw_ver = i2c_smbus_read_byte_data(client, fw_reg);
148148
if (fw_ver < 0) {
149-
dev_err(&client->dev, "i2c read error[%d]\n", error);
149+
dev_err(&client->dev, "i2c read error[%d]\n", fw_ver);
150150
return fw_ver;
151151
}
152152
dev_info(&client->dev, "Firmware version: %d\n", fw_ver);

0 commit comments

Comments
 (0)