]> git.itanic.dy.fi Git - linux-stable/commit
Input: mcs-touchkey - fix uninitialized use of error in mcs_touchkey_probe()
authorNathan Chancellor <nathan@kernel.org>
Tue, 25 Jul 2023 15:37:56 +0000 (08:37 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 25 Jul 2023 16:51:13 +0000 (09:51 -0700)
commit8362bf82fb5441613aac7c6c9dbb6b83def6ad3b
tree81b105ecfe0783ab1bc040e359e00075848f5579
parent447c09544275663e1082f796b26c7959915c922a
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: https://github.com/ClangBuiltLinux/linux/issues/1893
Fixes: e175eae16c1b ("Input: mcs-touchkey - convert to use devm_* api")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20230725-mcs_touchkey-fix-wuninitialized-v1-1-615db39af51c@kernel.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/keyboard/mcs_touchkey.c