mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] serial: lpuart: Avoid division by zero when requested baudrate is
Date: Sat, 11 Aug 2018 12:35:39 -0700	[thread overview]
Message-ID: <CAHQ1cqF5a0uCKZw08Adr0Uu0eexZ+xgyZNWemVYtnsXLiKEuPw@mail.gmail.com> (raw)
In-Reply-To: <20180515060727.j6zcpqcu7vwbd3bn@pengutronix.de>

On Mon, May 14, 2018 at 11:07 PM Sascha Hauer <s.hauer@pengutronix.de> wrote:
>
> On Mon, May 14, 2018 at 05:20:56PM -0700, Andrey Smirnov wrote:
> > On Mon, May 14, 2018 at 12:14 AM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > > On Tue, May 08, 2018 at 02:15:02PM -0700, Andrey Smirnov wrote:
> > >> With serdev device support added there's now a corner case where:
> > >>
> > >>  1. There is a DT node for a serdev device on one of the UARTs
> > >>  2. There is no driver that binds against serdev device's compatibility
> > >>     string
> > >>
> > >> with 1 and 2 being true it is possible to end up in a situation where
> > >> a particualr UART has not been initalized to any baudrate when
> > >> clock_notifier_call_chain() gets called. This effectively translates
> > >> to
> > >>
> > >>       set_baudrate(uart, 0);
> > >>
> > >> which for LPUART driver result in a division by zero.
> > >
> > > This probably leads to a division by zero for most drivers since
> > > dividing by the baudrate is a common pattern. Wouldn't it be better to
> > > catch this is console_set_baudrate()?
> > >
> >
> > It would, but none of the drivers that register a callback with
> > clock_register_client() (serial_imx.c, serial_auart.c, stm-serial.c,
> > serial_lpuart.c and serial_cadence.c) use console_set_badrate() and
> > instead call ->setbrg() directly. Probably because
> > console_set_baudrate() also handles interactive baudrate switch for
> > f_active console devices. Serial_imx.c doesn't preform any division,
> > so it is safe and I can go through the rest of them to add appropriate
> > checks? Another option is probably to try to come up with common
> > clock_register_client() infrastructure(since all of the handlers are
> > the same) and keep that check there.
> >
> > Let me know if you want me to do either.
>
> I see. For the sake of simplicity I think we can go with your original
> patch. In the auart and cadence driver the clock notify stuff is unused,
> only copy paste leftover from copying the i.MX driver. That leaves the
> lpuart driver which really has this problem.
>

Sascha, I don't think this patch ever made it into master. I am
assuming it just slipped through the cracks. Let me know if anything
needs changing for it to be applied.

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-08-11 19:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08 21:15 Andrey Smirnov
2018-05-14  7:14 ` Sascha Hauer
2018-05-15  0:20   ` Andrey Smirnov
2018-05-15  6:07     ` Sascha Hauer
2018-08-11 19:35       ` Andrey Smirnov [this message]
2018-08-13  7:14         ` Sascha Hauer

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=CAHQ1cqF5a0uCKZw08Adr0Uu0eexZ+xgyZNWemVYtnsXLiKEuPw@mail.gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.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