public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] dm: timer: refuse timers with zero clock_rate
Date: Mon, 11 Jan 2016 09:48:50 -0700	[thread overview]
Message-ID: <5693DCF2.20701@wwwdotorg.org> (raw)
In-Reply-To: <CAEUhbmVC1WPtAtBChpuD1ZbYry1g5K7XmOc_NXjXrX7YBihNcg@mail.gmail.com>

On 01/06/2016 10:29 PM, Bin Meng wrote:
> On Thu, Jan 7, 2016 at 1:33 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
>> From: Stephen Warren <swarren@nvidia.com>
>>
>> If a timer has a zero clock_rate, get_tbclk() will return zero for it,
>> which will cause tick_to_time() to perform a division-by-zero, which will
>> crash U-Boot.
>>
>> Signed-off-by: Stephen Warren <swarren@nvidia.com>
>> ---
>>   drivers/timer/timer-uclass.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/timer/timer-uclass.c b/drivers/timer/timer-uclass.c
>> index aca421bdea33..0771562c600d 100644
>> --- a/drivers/timer/timer-uclass.c
>> +++ b/drivers/timer/timer-uclass.c
>> @@ -47,6 +47,16 @@ static int timer_pre_probe(struct udevice *dev)
>>          return 0;
>>   }
>>
>> +static int timer_post_probe(struct udevice *dev)
>> +{
>> +       struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
>> +
>> +       if (!uc_priv->clock_rate)
>> +               return -EINVAL;
>
> Should we just panic here?

That would prevent the system operating correctly if multiple timers 
happened to be registered and the other one didn't have this issue. 
Still, it does seem reasonable to highlight this error. Simon, what do 
you think here?

  reply	other threads:[~2016-01-11 16:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-06 17:33 [U-Boot] [PATCH 1/3] dm: timer: refuse timers with zero clock_rate Stephen Warren
2016-01-06 17:33 ` [U-Boot] [PATCH 2/3] timer: sandbox: work without device tree Stephen Warren
2016-01-07  5:31   ` Bin Meng
2016-01-11 16:58   ` Simon Glass
2016-01-16  1:26     ` Simon Glass
2016-01-06 17:33 ` [U-Boot] [PATCH 3/3] test/py: add a test for the sleep command Stephen Warren
2016-01-11 15:23   ` Simon Glass
2016-01-15 18:24   ` Stephen Warren
2016-01-21  2:16     ` Simon Glass
2016-01-07  5:29 ` [U-Boot] [PATCH 1/3] dm: timer: refuse timers with zero clock_rate Bin Meng
2016-01-11 16:48   ` Stephen Warren [this message]
2016-01-11 16:56   ` Simon Glass
2016-01-16  1:26     ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5693DCF2.20701@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox