ANDROID: memory_state_time: fix undefined behavior with missing DT properties
authorArnd Bergmann <arnd@arndb.de>
Wed, 10 May 2017 09:21:27 +0000 (11:21 +0200)
committerAmit Pundir <amit.pundir@linaro.org>
Thu, 25 May 2017 11:07:25 +0000 (16:37 +0530)
commit4e29930f9b27e6671638e6c80935ef8603345bc8
tree9361ec8d913061c4c8d2063d495e1668bb010687
parent48d735173e0141626a5513fcc60aeba151ef84b2
ANDROID: memory_state_time: fix undefined behavior with missing DT properties

kernelci reports warnings about unintialized variable usage:

drivers/misc/memory_state_time.c:351:12: warning: 'lenf' is used uninitialized in this function [-Wuninitialized]
drivers/misc/memory_state_time.c:321:14: warning: 'lenb' is used uninitialized in this function [-Wuninitialized]

In both cases we try to continue without a DT property but use the
length that has not been assigned at this point. This rearranges the
code in the two functions to bail out earlier in case of an error.

The patch is needed for both android-common-4.9, 4.4 and 3.18.

Link: https://kernelci.org/build/id/591177f459b5147648b12d54/logs/
Fixes: ad3c02f8b3a5 ("ANDROID: Implement memory_state_time, used by qcom,cpubw")
Cc: James Carr <carrja@google.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/misc/memory_state_time.c