summaryrefslogtreecommitdiff
path: root/drivers/mmc
diff options
context:
space:
mode:
authorPavel Machek <pavel@ucw.cz>2019-04-16 09:58:45 +0200
committerUlf Hansson <ulf.hansson@linaro.org>2019-04-29 12:37:11 +0200
commit42c38d4a1bc41e78dedbf73b0fb35e44007789bb (patch)
tree340bfe840413ec655d0c4ccf509f7a587ab0531f /drivers/mmc
parent4c94cb651f478e0b53f10b77033b91a5c7702740 (diff)
mmc: core: Fix warning and undefined behavior in mmc voltage handling
!voltage_ranges is tested for too late, allowing warning and undefined behavior. Fix that. Signed-off-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/host.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 3a4402a79904..b3fa9c916142 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -363,11 +363,11 @@ int mmc_of_parse_voltage(struct device_node *np, u32 *mask)
int num_ranges, i;
voltage_ranges = of_get_property(np, "voltage-ranges", &num_ranges);
- num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
if (!voltage_ranges) {
pr_debug("%pOF: voltage-ranges unspecified\n", np);
return 0;
}
+ num_ranges = num_ranges / sizeof(*voltage_ranges) / 2;
if (!num_ranges) {
pr_err("%pOF: voltage-ranges empty\n", np);
return -EINVAL;