]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
regulator: s5m8767: fix get_register() error handling
authorArnd Bergmann <arnd@arndb.de>
Tue, 16 Feb 2016 14:53:11 +0000 (15:53 +0100)
committerKamal Mostafa <kamal@canonical.com>
Mon, 16 May 2016 17:26:44 +0000 (10:26 -0700)
commitea9dd33b635fd2e7dd650533eb8d53e0088c7779
tree25950d8c66456d1dcc00c07151f1dff225d7f5ef
parent7e6da14b415c940b6451ed2e2b21ff850838fe53
regulator: s5m8767: fix get_register() error handling

BugLink: http://bugs.launchpad.net/bugs/1578798
commit e07ff9434167981c993a26d2edbbcb8e13801dbb upstream.

The s5m8767_pmic_probe() function calls s5m8767_get_register() to
read data without checking the return code, which produces a compile-time
warning when that data is accessed:

drivers/regulator/s5m8767.c: In function 's5m8767_pmic_probe':
drivers/regulator/s5m8767.c:924:7: error: 'enable_reg' may be used uninitialized in this function [-Werror=maybe-uninitialized]
drivers/regulator/s5m8767.c:944:30: error: 'enable_val' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This changes the s5m8767_get_register() function to return a -EINVAL
not just for an invalid register number but also for an invalid
regulator number, as both would result in returning uninitialized
data. The s5m8767_pmic_probe() function is then changed accordingly
to fail on a read error, as all the other callers of s5m8767_get_register()
already do.

In practice this probably cannot happen, as we don't call
s5m8767_get_register() with invalid arguments, but the gcc
warning seems valid in principle, in terms writing safe
error checking.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 9c4c60554acf ("regulator: s5m8767: Convert to use regulator_[enable|disable|is_enabled]_regmap")
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
drivers/regulator/s5m8767.c