* [PATCH] Fix warning and undefined behavior in mmc voltage handling
@ 2019-04-12 9:34 Pavel Machek
2019-04-16 7:48 ` Ulf Hansson
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2019-04-12 9:34 UTC (permalink / raw)
To: ulf.hansson, kernel list, Andrew Morton, Trivial patch monkey
[-- Attachment #1: Type: text/plain, Size: 1032 bytes --]
!voltage_ranges is tested for too late, allowing warning and undefined
behavior. Fix that.
Signed-off-by: Pavel Machek <pavel@ucw.cz>
---
Plus I guess author should add parenthesis in the expression. a / b /
c is _not_ common idiom.
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 3a4402a..b3fa9c9 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;
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix warning and undefined behavior in mmc voltage handling
2019-04-12 9:34 [PATCH] Fix warning and undefined behavior in mmc voltage handling Pavel Machek
@ 2019-04-16 7:48 ` Ulf Hansson
2019-04-16 8:00 ` Pavel Machek
0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2019-04-16 7:48 UTC (permalink / raw)
To: Pavel Machek; +Cc: kernel list, Andrew Morton, Trivial patch monkey
On Fri, 12 Apr 2019 at 11:34, Pavel Machek <pavel@ucw.cz> wrote:
>
> !voltage_ranges is tested for too late, allowing warning and undefined
> behavior. Fix that.
>
> Signed-off-by: Pavel Machek <pavel@ucw.cz>
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
>
> ---
>
> Plus I guess author should add parenthesis in the expression. a / b /
> c is _not_ common idiom.
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 3a4402a..b3fa9c9 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;
>
> --
> (english) http://www.livejournal.com/~pavelmachek
> (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix warning and undefined behavior in mmc voltage handling
2019-04-16 7:48 ` Ulf Hansson
@ 2019-04-16 8:00 ` Pavel Machek
2019-04-16 9:28 ` Ulf Hansson
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Machek @ 2019-04-16 8:00 UTC (permalink / raw)
To: Ulf Hansson; +Cc: kernel list, Andrew Morton, Trivial patch monkey
[-- Attachment #1: Type: text/plain, Size: 1026 bytes --]
On Tue 2019-04-16 09:48:51, Ulf Hansson wrote:
> On Fri, 12 Apr 2019 at 11:34, Pavel Machek <pavel@ucw.cz> wrote:
> >
> > !voltage_ranges is tested for too late, allowing warning and undefined
> > behavior. Fix that.
> >
> > Signed-off-by: Pavel Machek <pavel@ucw.cz>
>
> 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.
> > 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?
> > - 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
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix warning and undefined behavior in mmc voltage handling
2019-04-16 8:00 ` Pavel Machek
@ 2019-04-16 9:28 ` Ulf Hansson
0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2019-04-16 9:28 UTC (permalink / raw)
To: Pavel Machek; +Cc: kernel list, Andrew Morton, Trivial patch monkey
On Tue, 16 Apr 2019 at 10:00, Pavel Machek <pavel@ucw.cz> wrote:
>
> On Tue 2019-04-16 09:48:51, Ulf Hansson wrote:
> > On Fri, 12 Apr 2019 at 11:34, Pavel Machek <pavel@ucw.cz> wrote:
> > >
> > > !voltage_ranges is tested for too late, allowing warning and undefined
> > > behavior. Fix that.
> > >
> > > Signed-off-by: Pavel Machek <pavel@ucw.cz>
> >
> > 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!
>
> > > 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.
>
> > > - 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-04-16 9:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12 9:34 [PATCH] Fix warning and undefined behavior in mmc voltage handling Pavel Machek
2019-04-16 7:48 ` Ulf Hansson
2019-04-16 8:00 ` Pavel Machek
2019-04-16 9:28 ` Ulf Hansson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).