All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Stevenson <dave.stevenson@raspberrypi.com>
To: Josua Mayer <josua@solid-run.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>,
	matrandg@cisco.com, Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: Re: [PATCH] media: tc358743: fix missing return of error code in tc358743_probe_of
Date: Wed, 23 Jun 2021 11:05:58 +0100	[thread overview]
Message-ID: <CAPY8ntCo+GSvPjcKxK52C8SEN8JMhFOo+yOPYRhgaNoA7wKsYA@mail.gmail.com> (raw)
In-Reply-To: <20210622203329.11608-1-josua@solid-run.com>

Hi Josua

Thanks for the patch.

On Tue, 22 Jun 2021 at 21:33, Josua Mayer <josua@solid-run.com> wrote:
>
> When device-tree configures an unsupported combinaion of number of lanes,

s/combinaion/combination

> and link frequency, e.g. by exceeding 1Gbps per lane, 0 is returned,
> wrongly indicating success. In this case, return EINVAL instead!

The change you've provided is in the check that the lane link
frequency is within range only. Nothing to do with the number of
lanes.

> This fixes a divide-by-zero crash in tc358743_num_csi_lanes_needed,
> where the divisor becomes zero because pll_fbd has been left at 0 by probe.

There's a very similar case in this function if the refclk frequency
is not supported.
That will cause a divide-by-zero when calculating pll_fbd with a 0
pll_prd value.

@@ -1980,6 +1980,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
        default:
                dev_err(dev, "unsupported refclk rate: %u Hz\n",
                        state->pdata.refclk_hz);
+               ret = -EINVAL;
                goto disable_clk;
        }

Could you roll that one in too?

Cheers
  Dave

> Signed-off-by: Josua Mayer <josua@solid-run.com>
> ---
>  drivers/media/i2c/tc358743.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/i2c/tc358743.c b/drivers/media/i2c/tc358743.c
> index 1b309bb743c7..f21da11caf22 100644
> --- a/drivers/media/i2c/tc358743.c
> +++ b/drivers/media/i2c/tc358743.c
> @@ -1974,6 +1974,7 @@ static int tc358743_probe_of(struct tc358743_state *state)
>         bps_pr_lane = 2 * endpoint.link_frequencies[0];
>         if (bps_pr_lane < 62500000U || bps_pr_lane > 1000000000U) {
>                 dev_err(dev, "unsupported bps per lane: %u bps\n", bps_pr_lane);
> +               ret = -EINVAL;
>                 goto disable_clk;
>         }
>
> --
> 2.32.0
>

      reply	other threads:[~2021-06-23 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09 15:07 [BUG] tc358743: division by zero Ing. Josua Mayer
2021-06-09 15:08 ` Ing. Josua Mayer
2021-06-09 17:08   ` Ing. Josua Mayer
2021-06-09 17:27     ` Dave Stevenson
2021-06-21 14:58       ` Ing. Josua Mayer
2021-06-22 20:33 ` [PATCH] media: tc358743: fix missing return of error code in tc358743_probe_of Josua Mayer
2021-06-23 10:05   ` Dave Stevenson [this message]

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=CAPY8ntCo+GSvPjcKxK52C8SEN8JMhFOo+yOPYRhgaNoA7wKsYA@mail.gmail.com \
    --to=dave.stevenson@raspberrypi.com \
    --cc=josua@solid-run.com \
    --cc=linux-media@vger.kernel.org \
    --cc=matrandg@cisco.com \
    --cc=mchehab@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.