summaryrefslogtreecommitdiff
path: root/drivers/power/test_power.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/test_power.c')
-rw-r--r--drivers/power/test_power.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/power/test_power.c b/drivers/power/test_power.c
index 83c42ea88f2b..57246cdbd042 100644
--- a/drivers/power/test_power.c
+++ b/drivers/power/test_power.c
@@ -301,6 +301,8 @@ static int map_get_value(struct battery_property_map *map, const char *key,
buf[MAX_KEYLENGTH-1] = '\0';
cr = strnlen(buf, MAX_KEYLENGTH) - 1;
+ if (cr < 0)
+ return def_val;
if (buf[cr] == '\n')
buf[cr] = '\0';