Commit 42c38d4a authored by Pavel Machek's avatar Pavel Machek Committed by Ulf Hansson

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: default avatarPavel Machek <pavel@ucw.cz>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 4c94cb65
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment