Fix warning and undefined behavior in mmc voltage handling
PATCH 1/1 Fix warning and undefined behavior in mmc voltage handling
!voltage_ranges is tested for too late, allowing warning and undefined behavior. Fix that.
---
Plus I guess author should add parenthesis in the expression. a / b / c is _not_ common idiom.
drivers/mmc/core/host.c +1 -1
@@ -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 ;
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 5 lines · Pavel Machek
!voltage_ranges is tested for too late, allowing warning and undefined behavior. Fix that.
Signed-off-by Pavel Machek <[email protected]>
Pavel, thanks for your patch.
Would you mind re-posting to linux-mmc so I can get it into the patchtracker. Please also change the prefix of the header to "mmc:
core:".
Otherwise this looks good to me.
Kind regards
Uffe
Quoted 27 lines
---
Plus I guess author should add parenthesis in the expression. a / b / c is _not_ common idiom.
drivers/mmc/core/host.c +1
-2@@ -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 ; --(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 5 lines · Ulf Hansson
Quoted 4 lines · Pavel Machek
!voltage_ranges is tested for too late, allowing warning and undefined behavior. Fix that.
Quoted 7 lines
Quoted 1 line
Signed-off-by Pavel Machek <[email protected]>Pavel, thanks for your patch.
Would you mind re-posting to linux-mmc so I can get it into the patchtracker. Please also change the prefix of the header to "mmc:
core:".
Done.
Quoted 2 lines
Quoted 2 lines
Plus I guess author should add parenthesis in the expression. a / b / c is _not_ common idiom.
Can you do something about the a / b / c situation?
Quoted 2 lines
drivers/mmc/core/host.c int mmc_of_parse_voltage(struct device_node *np, u32 *mask) · line 370
Quoted 2 lines
drivers/mmc/core/host.c +1
-1- num_ranges = num_ranges /sizeof (*voltage_ranges) /2 ; + num_ranges = num_ranges /sizeof (*voltage_ranges) /2 ;
I guess it is:
num_ranges = (num_ranges / sizeof(*voltage_ranges)) / 2;
...but...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 9 lines · Pavel Machek
Quoted 7 lines · Ulf Hansson
Quoted 5 lines · Pavel Machek
!voltage_ranges is tested for too late, allowing warning and undefined behavior. Fix that.
Signed-off-by Pavel Machek <[email protected]>
Quoted 7 lines
Quoted 5 lines
Pavel, thanks for your patch.
Would you mind re-posting to linux-mmc so I can get it into the patchtracker. Please also change the prefix of the header to "mmc:
core:".Done.
Thanks!
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Plus I guess author should add parenthesis in the expression. a / b / c is _not_ common idiom.
Can you do something about the a / b / c situation?
Sure.
Quoted 6 lines
Quoted 3 lines
drivers/mmc/core/host.c int mmc_of_parse_voltage(struct device_node *np, u32 *mask) · line 370
Quoted 3 lines
drivers/mmc/core/host.c +1
-1- num_ranges = num_ranges /sizeof (*voltage_ranges) /2 ; + num_ranges = num_ranges /sizeof (*voltage_ranges) /2 ;I guess it is:
num_ranges = (num_ranges / sizeof(*voltage_ranges)) / 2;
Just send a patch on top, then I will apply it.
Kind regards
Uffe